Your First App: Prerequisites

Before you can start coding your first client application, there are a few things you need to do, if you haven't done them already.

Create a Google Account and get DS permissions

To use the DoubleClick Search API, you need a Google Account and appropriate permissions granted to that account from DoubleClick Search:

  1. If you don't already have a Google Account, create one.

  2. Ask a DoubleClick Search Agency Manager to create a DoubleClick Search user for your Google Account.

    To download reports, you'll need view permission for the advertisers you'll be working with.

    To add or edit conversions, you'll need edit permission for the advertisers you'll be working with.

    The Agency Manager can set up your account as an Advertiser user with access to specific advertisers, or set up your account with a higher level of access such as Agency user with access to all advertisers in the agency.

Activate the API Conversion Service

If you want to upload data about conversions, a DoubleClick Search user with Agency Manager privileges needs to sign in to the DoubleClick Search UI and activate the API conversion service. See the DoubleClick Search help center for instructions.

Create a Google API Console project and OAuth credentials for your client

  1. Start the Google API Console setup tool.
    The setup tool guides you through creating a project (or using an existing project), enabling the DoubleClick Search API, and creating OAuth 2.0 credentials.
  2. On the Register your application page, select an existing project or select Create a project. Then click Continue.
  3. After the Google API Console enables the DoubleClick Search API, click the Go to credentials button.
  4. On the Add credentials to your project page, enter the following information:
    • Which API are you using?: DoubleClick Search API
    • Where will you be calling the API from?: Other UI (e.g., Windows, CLI tool)
    • What data will you be accessing?: User data
  5. Click the What credentials do I need? button.

    The setup tool now offers to help you create an OAuth 2.0 client ID.

  6. Click Create client ID and follow the rest of the steps in the setup tool.

Install dsApi.py

DoubleClick Search provides a utility script to facilitate the process of setting up authorization. You can also use this script to send and receive data in the JSON format, if you want to try sending and receiving data before you design and write a full application. You can copy many of the JSON examples in this documentation site and input them directly to the script.

To install the script:

  1. Install Python 2.7 or better.
  2. Install cURL.
  3. Download dsApi.zip.
  4. Extract dsApi.py from dsApi.zip.
  5. Make dsApi.py executable.

Learn REST basics

There are two ways to invoke the API:

If you decide not to use client libraries, you'll need to understand the basics of REST.

REST is a style of software architecture that provides a convenient and consistent approach to requesting and modifying data.

The term REST is short for "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.

In 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.

In 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:

https://www.googleapis.com/apiName/apiVersion/resourcePath?parameters

Because all API resources have unique HTTP-accessible URIs, REST enables data caching and is optimized to work with the web's distributed infrastructure.

You may find the method definitions in the HTTP 1.1 standards documentation useful; they include specifications for GET, POST, PUT, and DELETE.

REST in the DoubleClick Search API

The DoubleClick Search API operations map directly to REST HTTP verbs.

The specific format for DoubleClick Search API URIs is:

https://www.googleapis.com/doubleclick-search/v2/resourcePath?parameters

The full set of URIs used for each supported operation in the API is summarized in the API Reference.

Learn JSON basics

If you use REST, you'll need to use the JSON format for the request bodies. You can specify that the responses be either in the JSON or CSV format.

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.

发送以下问题的反馈:

此网页
DoubleClick Search API