from aw_api.Errors import ApiError # Initialize Client object. The "path" parameter should point to the location of # pickles, which get generated after execution of "aw_api_config.py" script. The # same location is used for the "logs/" directory, if logging is enabled. client = Client(path='../..') # Temporarily disable debugging. If enabled, the debugging data will be send to # STDOUT. client.debug = False # Construct SOAP message by loading XML from existing data file. soap_message = Utils.ReadFile( os.path.join(LIB_HOME, 'data', 'request_getaccountinfo.xml')) url = '/api/adwords/%s/AccountService' % MIN_API_VERSION http_proxy = None try: response = client.CallRawMethod(soap_message, url, http_proxy)[0] # Display results. print 'Response:\n%s' % response except ApiError, e: print 'Note: this should fail, unless you provide valid authentication data.' print raise e print print('Usage: %s units, %s operations' % (client.GetUnits(), client.GetOperations()))
import sys sys.path.append('../..') # Import appropriate classes from the client library. from aw_api.Client import Client # Initialize client object. client = Client(path='../..') # Initialize appropriate service. report_definition_service = client.GetReportDefinitionService( 'https://adwords-sandbox.google.com', 'v201003') report_type = 'INSERT_REPORT_TYPE_HERE' # Get report fields. fields = report_definition_service.GetReportFields(report_type) # Display results. print 'Report type \'%s\' contains the following fields:' % report_type for field in fields: print ' - %s (%s)' % (field['fieldName'], field['fieldType']) if field['enumValues']: print ' := [%s]' % ', '.join(field['enumValues']) print print ('Usage: %s units, %s operations' % (client.GetUnits(), client.GetOperations()))