Seu primeiro aplicativo: pré-requisitos
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Antes de começar a codificar seu primeiro aplicativo cliente, há algumas coisas que você
precisa fazer, se ainda não tiver feito.
Criar uma Conta do Google e receber permissões do Search Ads 360
Para usar a API Search Ads 360, você precisa de uma Conta do Google e das permissões adequadas concedidas a essa conta pelo Search Ads 360:
Se você ainda não tem uma Conta do Google,
crie uma.
Peça a um administrador de agência do Search Ads 360 para
criar um usuário do Search Ads 360 para sua Conta do Google.
Para fazer o download de relatórios, você precisa de permissão de visualização dos anunciantes
com quem vai trabalhar.
Para adicionar ou editar conversões, você precisa ter permissão de edição para os anunciantes
com que vai trabalhar. Em uma configuração compartilhada do Floodlight, é necessário ter permissão de edição para cada anunciante filho em que você quer fazer o upload de conversões.
Não é preciso acessar o anunciante pai nem os anunciantes filhos de que você não está fazendo upload de conversões. Se você usa IDs de clique para atribuir conversões a visitas, verifique se tem acesso para editar ao anunciante que gerou o ID de clique. Se você especificar um ID de clique de um anunciante que não tem acesso para editar,
a solicitação não vai ser bem-sucedida.
O administrador da agência pode configurar sua conta como um usuário do anunciante com acesso a anunciantes específicos ou configurar sua conta com um nível mais alto de acesso, como Usuário da agência, com acesso a todos os anunciantes da agência.
Ativar o serviço de conversão da API
Se você quiser fazer o upload de dados sobre conversões, um usuário do Search Ads 360 com privilégios de gerente de agência precisará fazer login na interface do Search Ads 360 e ativar o serviço de conversão da API. Consulte a
Central de Ajuda do Search Ads 360 para ver instruções.
Criar um projeto do Console de APIs do Google e credenciais OAuth para seu cliente
- Inicie a
ferramenta de configuração do Console de APIs do Google.
A ferramenta de configuração orienta você na criação de um projeto (ou no uso de um projeto existente),
na ativação da API Search Ads 360 e na criação de credenciais OAuth 2.0.
- Na página Registrar seu aplicativo, selecione um projeto atual ou clique em
Criar um projeto. Em seguida, clique em Continuar.
- Depois que o Google API Console ativar a API Search Ads 360, clique no botão Acessar credenciais.
- Na página Criar credenciais, insira as seguintes informações:
-
Qual API você está usando?: Search Ads 360 API
-
Quais dados você vai acessar? Dados do usuário
- Clique no botão Próxima.
Agora, a ferramenta de configuração ajuda a criar um ID do cliente do OAuth 2.0.
- Siga as etapas restantes na ferramenta de configuração.
Instalar sa360Api.py
O Search Ads 360 oferece um script de utilitário para facilitar o processo de configuração da autorização. Você também pode usar esse script para enviar e receber dados no formato JSON,
se quiser tentar enviar e receber dados antes de projetar e escrever um aplicativo
completo. É possível copiar muitos dos exemplos JSON neste site de documentação e inseri-los diretamente no script.
Para instalar o script:
- Instale o Python 2.7.
O script não funciona com o Python 3.x.
- Instale o cURL.
- Faça o download do arquivo sa360Api.zip.
- Extraia
sa360Api.py
de sa360Api.zip
.
- Torne
sa360Api.py
executável.
Aprender os fundamentos da REST
Há duas maneiras de chamar a API:
Se você não quiser usar as bibliotecas de cliente, precisará entender os fundamentos da
REST.
REST é um estilo de arquitetura de software que fornece uma abordagem conveniente e consistente para solicitar e modificar dados.
O termo REST é a abreviação de "Representational State Transfer (Transferência de Estado Representacional)". No contexto das APIs do Google, ele se refere ao uso de verbos HTTP para recuperar e modificar representações de dados armazenados pelo Google.
Em um sistema RESTful, os recursos são mantidos em um armazenamento de dados. Um cliente envia uma solicitação para que uma ação específica seja executada no servidor, como a criação, recuperação, atualização ou exclusão de um recurso. Essa ação é executada e uma resposta é enviada, geralmente no formato de uma representação do recurso especificado.
Nas APIs RESTful do Google, uma ação é especificada no cliente usando um verbo HTTP como POST
, GET
, PUT
ou DELETE
. Um recurso é definido por meio de um URI global exclusivo no seguinte formato:
https://www.googleapis.com/apiName/apiVersion/resourcePath?parameters
Como todos os recursos da API têm URIs exclusivos acessíveis por HTTP, a REST permite o armazenamento em cache dos dados e é otimizada para funcionar na infraestrutura distribuída da Web.
As definições de método (em inglês) encontradas na documentação dos padrões HTTP 1.1 podem ser úteis. Nelas estão incluídas as especificações GET
, POST
, PUT
e DELETE
.
REST na API Search Ads 360
As operações da API Search Ads 360 são mapeadas diretamente para os verbos HTTP REST.
O formato específico dos URIs da API Search Ads 360 é:
https://www.googleapis.com/doubleclicksearch/v2/resourcePath?parameters
O conjunto completo de URIs usados para cada operação compatível na API está resumido na referência da API.
Conhecer os fundamentos do JSON
Se usar REST, você precisará usar o formato JSON para os corpos das solicitações. É possível
especificar que as respostas sejam no formato JSON ou CSV.
JSON (JavaScript Object Notation) é um formato de dados comum e independente de linguagem que oferece uma representação de texto simples das estruturas de dados arbitrárias. Para mais informações, acesse json.org (em inglês).
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2024-11-07 UTC.
[null,null,["Última atualização 2024-11-07 UTC."],[[["\u003cp\u003eBefore using the Search Ads 360 API, ensure you have a Google Account with the necessary Search Ads 360 permissions, which may include view or edit access to specific advertisers.\u003c/p\u003e\n"],["\u003cp\u003eTo upload conversion data, the API Conversion Service must be activated by a Search Ads 360 user with Agency Manager privileges.\u003c/p\u003e\n"],["\u003cp\u003eSet up a Google API Console project and obtain OAuth credentials for your client application to authenticate and authorize API access.\u003c/p\u003e\n"],["\u003cp\u003eInstall the provided \u003ccode\u003esa360Api.py\u003c/code\u003e utility script and familiarize yourself with REST and JSON basics if you plan to interact with the API directly without client libraries.\u003c/p\u003e\n"]]],["To start coding, create a Google Account and request Search Ads 360 permissions from an Agency Manager, who will grant view or edit access to advertisers. Activate the API conversion service via the Search Ads 360 UI. Next, create a Google API Console project and OAuth 2.0 credentials. Install Python 2.7, cURL, and the `sa360Api.py` utility script. Finally, understand REST basics and JSON formatting, crucial for interacting with the API using HTTP requests.\n"],null,["# Your First App: Prerequisites\n\nBefore you can start coding your first client application, there are a few things you\nneed to do, if you haven't done them already.\n\nCreate a Google Account and get Search Ads 360 permissions\n----------------------------------------------------------\n\nTo use the Search Ads 360 API, you need a Google Account and appropriate permissions\ngranted to that account from Search Ads 360:\n\n1. If you don't already have a Google Account, [create one](https://support.google.com/accounts/answer/27441).\n\n2. Ask a Search Ads 360 **Agency Manager** to [create a Search Ads 360 user](https://support.google.com/searchads/answer/6051717) for your Google Account.\n\n To download reports, you'll need **view permission** for the advertisers\n you'll be working with.\n\n To add or edit conversions, you'll need **edit permission** for the advertisers\n you'll be working with. In a\n [shared Floodlight configuration](https://support.google.com/searchads/answer/2458167),\n you need edit permission for each child advertiser you want to upload conversions into.\n You don't need access to the parent advertiser, nor do you need access to child advertisers\n that you're not uploading conversions into. If you use click IDs to\n [attribute\n conversions to visits](/search-ads/v2/how-tos/conversions/insert#attribute-a-conversion-to-a-specific-visit), make sure you have edit access to the advertiser that generated\n the click ID. If you specify a click ID from an advertiser you don't have edit access to,\n the request will not succeed.\n\n The Agency Manager can set up your account as an **Advertiser user** with\n access to specific advertisers,\n or set up your account with a higher level of access such as **Agency user**\n with access to all advertisers in the agency.\n\nActivate the API Conversion Service\n-----------------------------------\n\n\nIf you want to upload data about conversions, a Search Ads 360 user with **Agency\nManager** privileges needs to sign in to the Search Ads 360 UI and\n**activate the API conversion service** . See the\n[Search Ads 360\nhelp center](https://support.google.com/searchads/answer/2604604#activate) for instructions.\n\nCreate a Google API Console project and OAuth credentials for your client\n-------------------------------------------------------------------------\n\n1. Start the Google API Console [setup tool](https://console.cloud.google.com/start/api?id=doubleclicksearch&credential=client_key). \n The setup tool guides you through creating a project (or using an existing project), enabling the Search Ads 360 API, and creating OAuth 2.0 credentials.\n2. On the **Register your application** page, select an existing project or select **Create a project** . Then click **Continue**.\n3. After the Google API Console enables the Search Ads 360 API, click the **Go to credentials** button.\n4. On the **Create credentials** page, enter the following information:\n - **Which API are you using?**: Search Ads 360 API\n - **What data will you be accessing?**: User data\n5. Click the **Next** button.\n\n The setup tool now offers to help you create an **OAuth 2.0 client ID**.\n6. Follow the rest of the steps in the setup tool.\n\nInstall sa360Api.py\n-------------------\n\nSearch Ads 360 provides a utility script to facilitate the process of setting up\nauthorization. You can also use this script to send and receive data in the JSON format,\nif you want to try sending and receiving data before you design and write a full\napplication. You can copy many of the JSON examples in this documentation site and input\nthem directly to the script.\n\nTo install the script:\n\n1. [Install Python](http://www.python.org/getit/) 2.7. \n The script does not work with Python 3.x.\n2. [Install cURL](http://curl.haxx.se/download.html).\n3. [Download sa360Api.zip](https://www.google.com/help/hc/downloads/sa360/sa360Api.zip).\n4. Extract `sa360Api.py` from `sa360Api.zip`.\n5. Make `sa360Api.py` executable.\n\nLearn REST basics\n-----------------\n\nThere are two ways to invoke the API:\n\n- Using [client libraries](/search-ads/v2/libraries).\n- Sending HTTP requests and parsing the responses.\n\nIf you decide not to use client libraries, you'll need to understand the basics of\nREST.\n\nREST is a style of software architecture that provides a convenient and consistent approach to requesting and modifying data.\n\nThe term REST is short for \"[Representational State Transfer](https://en.wikipedia.org/wiki/Representational_state_transfer).\" In the context of Google APIs, it refers to using HTTP verbs to retrieve and modify representations of data stored by Google.\n\nIn a RESTful system, resources are stored in a data store; a client sends a request that the server perform a particular action (such as creating, retrieving, updating, or deleting a resource), and the server performs the action and sends a response, often in the form of a representation of the specified resource.\n\nIn Google's RESTful APIs, the client specifies an action using an HTTP verb such as `POST`, `GET`, `PUT`, or `DELETE`. It specifies a resource by a globally-unique URI of the following form: \n\n```\nhttps://www.googleapis.com/apiName/apiVersion/resourcePath?parameters\n```\n\nBecause all API resources have unique HTTP-accessible URIs, REST enables data caching and is optimized to work with the web's distributed infrastructure.\n\nYou may find the [method definitions](https://tools.ietf.org/html/rfc7231#section-4.3) in the HTTP 1.1 standards documentation useful; they include specifications for `GET`, `POST`, `PUT`, and `DELETE`.\n\n### REST in the Search Ads 360 API\n\nThe Search Ads 360 API operations map directly to REST HTTP verbs.\n\nThe specific format for Search Ads 360 API URIs is: \n\n```\nhttps://www.googleapis.com/doubleclicksearch/v2/resourcePath?parameters\n```\n\n\nThe full set of URIs used for each supported operation in the API is summarized in the [API Reference](/search-ads/v2/reference).\n\nLearn JSON basics\n-----------------\n\nIf you use REST, you'll need to use the JSON format for the request bodies. You can\nspecify that the responses be either in the JSON or CSV format.\n\n\n[JSON](http://en.wikipedia.org/wiki/JSON) (JavaScript Object Notation) is a common, language-independent data format that provides a simple text representation of arbitrary data structures. For more information, see [json.org](http://www.json.org/).\n\n\u003cbr /\u003e"]]