hockeyprincess / google-api-dfp-python

Automatically exported from code.google.com/p/google-api-dfp-python
Apache License 2.0
0 stars 0 forks source link

Google's DoubleClick for Publishers API Python Client Library

Google's DoubleClick for Publishers API service lets developers design computer programs that interact directly with the DFP platform. With these applications, advertisers and third parties can more efficiently -- and creatively -- manage their large or complex DFP accounts.

Google's DFP API Python Client Library makes it easy to write Python clients to programmatically access DFP accounts. One of the main features of this client library is that it hides the SOAP layer from end users, which makes it much easier to interact with API. The outgoing and incoming SOAP messages are monitored and logged on demand. The response headers like responseTime, requestId, etc. can also be logged on demand. Another nice feature of this client library is that it handles data types for all API call parameters. You no longer need to remember that Date.hour is of type int and Company.id is of type long. Both of these variables can now be sent as simple strings, when passing them as parameters. In fact, all variables are passed as either dict, list, or str. The conversion to the right type is handled internally by the client library.

The client library provides support for SOAPpy and ZSI, which are two well known web services toolkits from http://pywebsvcs.sourceforge.net/. A single implementation of the client code can be used with either toolkit. Once you decide which SOAP toolkit to use, client library will take care of proper type conversions, instantiation of classes, etc.

The two toolkits are very different and both have their pluses and minuses. The SOAPpy toolkit hasn't been updated for some time. The latest version 0.12.0_rc1 is dated 2005-02-22. However, from the tests, it seem to be faster than ZSI. On the other hand, ZSI is the primary and most active web services toolkit from the "Python Web Services" project.

Two modules are supported for parsing SOAP XML messages. By default, the client library uses the PyXML module in order to parse SOAP XML messages. In addition, the library also supports ElementTree module, which may be activated simply by setting the appropriate config value (i.e. config['xml_parser']). Note that if you already have an lxml module installed and wish to use ElementTree, you do not need to install ElementTree. The lxml module is mostly compatible with ElementTree. The cElementTree module is now also supported. Note that when ElementTree module is used and PrettyPrintXml is enabled, the logged XML is slightly different from what gets sent over the wire.

Although there are projects out there that still support PyXML, it is no longer maintained. The last update for the ElementTree library is dated 2007-09-12. Out of these three libraries, the lxml is the one that was updated most recently. Also, if you have Python v2.5+, the ElementTree comes with it.

Although, there are projects out there that still support PyXML, it is no longer maintained. The last update for ElementTree library is dated 2007-09-12. Out of these three libraries, the lxml is the one that was updated most recently.

The code examples, located in "examples/", demonstrate how to use client library. For additional examples, take a look at the unit tests in "tests/".

Useful scripts are located in the "scripts/" directory.

The documentation was generated using Epydoc, a nice tool for generating API documentation for Python modules, and is located in "docs/".

The client library includes a set of unit tests located in "tests/". All unit tests are (and should be) executed against the Sandbox environment. Whenever changes are made to the client library, the appropriate unit test should be executed to make sure that everything is working as intended and no new bugs were introduced.

How do I start?

If you haven't yet done so, you'll need to request sandbox access to the API as directed on this page: http://code.google.com/apis/dfp/docs/signup.html. Once that's taken care of, proceed to the step-by-step guide below. Write some code and enjoy!

Step-by-step guide for accessing the sandbox:

1) Make sure you have Python v2.4 or above installed. The latest stable version can be fetched from http://www.python.org/.

2) One of the two web services toolkits is needed, either SOAPpy or ZSI. Both of them can be fetched from http://pywebsvcs.sourceforge.net/.

3) Fetch the latest version of the PyXML module from http://sourceforge.net/projects/pyxml/. This is required by the client library.

4) Sign up for a Google Account. In later steps, we'll assume that the new login is joe.shmoe@gmail.com.

5) Navigate to the directory that contains your downloaded unzipped client library and run the "setup.py" script to install the "adspygoogle.dfp" module.

$ python setup.py build install

6) From the same directory, run the "config.py" script to set authentication headers. More information about the format of each header is at http://code.google.com/apis/dfp/docs/developers_guide.html#headers. Example,

Login email: joe.shmoe@gmail.com Login password: secret Network code [optional]: Application name: GoogleTest

Select SOAP library [1=SOAPpy, 2=ZSI]: 2 Select XML parser [1=PyXML, 2=ElementTree]: 1 Enable debugging mode [y/n]: n Enable SOAP XML logging mode [y/n]: y Enable API request logging mode [y/n]: y

7) Read over the documentation in "docs/index.html" to familiarize yourself with the API of the client library.

Where do I submit bug reports and/or feature requests?

Use the issue tracker at http://code.google.com/p/google-api-dfp-python/issues/list.

External Dependencies:

- Python v2.4+         -- http://www.python.org/
- PyXML v0.8.3+        -- http://sourceforge.net/projects/pyxml/
                       or
  ElementTree v1.2.6+  -- http://effbot.org/zone/element-index.htm
                       or
  cElementTree v1.0.6+ -- http://www.python.org/
                       (part of the Python v2.5+)
                       or
  lxml v2.2+           -- http://codespeak.net/lxml/index.html
- SOAPpy v0.12.0       -- http://pywebsvcs.sourceforge.net/
                       or
  ZSI v2.0             -- http://pywebsvcs.sourceforge.net/
                       (requires PyXML v0.8.3+)
- Epydoc               -- http://epydoc.sourceforge.net/
                       (only if you will be generating docs)
- Google Account       -- https://www.google.com/accounts/NewAccount

Author: api.sgrinberg@gmail.com (Stan Grinberg)