>> Koleda: Hi, I'm Eric Koleda, with the Google Developer Relations Team. This screencast
will show you how to get started with the AdWords API Python Client Library. The library
requires Python version 2.4 and higher, and the modules; ZSI and PyXML. The first thing
we need to do is download the library. The best way to find it is by going to the AdWords
API documentation at code.google.com/api/adwords. Click on Docs, Libraries and Samples, and
Python Client Library. This is the main project page of the Client Library. On the right side
of the page is a convenient link to download the latest version of the library. Once the
download is complete, extract it to a folder of your choice.
The first thing we need to do is install the library. Open a command prompt and navigate
to the folder you extracted the library to. Next, run the "script, setup.py" with the
parameters, "build and install". Now that the Library is installed, we can set the authentication
and configuration information. To do that, run the script "awapiconfig.py". This will
launch an interactive script which will ask you for the required configuration values.
When testing a new library, it's best to use a Sandbox account. More information on the
Sandbox environment is available on the screencast inferred to the AdWords API Sandbox. Enter
your Sandbox credentials, starting with the email, password, client email that will contain
one of the automatically generated client accounts. We don't need a client customer
ID since we specified the client email, the user agent that identifies your application,
a Developer Token which in the Sandbox is the email address, plus, plus a currency code.
The Application Token is ignored in the Sandbox, the SOAP Library, ZSI in this case will disable
debugging mode which displays the raw SOAP XML request as they are being made, but enables
SOAP XML logging and request logging. We're now ready to run our first example. Navigate
to the examples directory and then the subdirectory for the version of the API you wish to test.
We'll start by running the example, "get_all_campaigns.py". Since this is a new a Sandbox account, there
are no existing campaigns. We can add a campaign by running "add_campaign.py", and a new campaign
was created with the ID and name shown. If we rerun "get_all_campaigns", we can see that
the new campaign was found. As we can see, the campaign was initially created in a pause
state, so let's write our own example to make it active. Browse to the examples folder,
must create a new file called "activate_campaign.py", and then open it in a Text Editor. We'll start
by setting up our import statements. Client is the main class of the library, and it's
used to connect to the various services. Next, we'll create a new client object, setting
the path parameter to the directory where the authentication and configuration files
are stored. We'll get an instance of the campaign service by running "client.GetCampaignService",
passing in the server and version of the API. Next, we'll set the campaign ID. This value
can be retrieved from the output of the previous examples.
Next, we'll create our operations, which is an array of dictionary objects. Since we are
updating the campaign, we'll set the operator to set and the operand to a campaign object
with the ID that was set earlier, and the status of active. We're now ready to make
a request against the API by calling the Campaign Service Mutate Method passing in the operations
we've defined. Finally, we'll loop over the returned campaigns displaying the updated
information. We can save this file and go back to our command prompt. We can now run
"activate_campaign.py". The request was successful and the campaign was
returned with the status active. For notification of new versions of the Client Library, subscribe
to the Project Feeds. New services will be announced on the AdWords API Blog. And if
you have any questions about using the API, contact the AdWords API Forum. Finally, if
you find any bugs in the Library, submit an issue to the Issue Tracker. Thank you for
your time and enjoy using the Client Library.