How to use the googleads.adwords.AdWordsClient function in googleads

To help you get started, we’ve selected a few googleads examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleads / googleads-python-lib / examples / adwords / v201705 / misc / get_all_images_and_videos.py View on Github external
dimensions['FULL']['height'],
                                  dimensions['FULL']['width'],
                                  image['mimeType']))
        elif image['type'] == 'VIDEO':
          print ('%s with id "%s" was found.' % (image['type'],
                                                 image['mediaId']))
    else:
      print 'No images/videos were found.'
    offset += PAGE_SIZE
    selector['paging']['startIndex'] = str(offset)
    more_pages = offset < int(page['totalNumEntries'])


if __name__ == '__main__':
  # Initialize client object.
  adwords_client = adwords.AdWordsClient.LoadFromStorage()

  main(adwords_client)
github googleads / googleads-python-lib / examples / adwords / v201809 / campaign_management / set_ad_parameters.py View on Github external
}
      }
  ]
  ad_params = ad_param_service.mutate(operations)

  # Display results.
  for ad_param in ad_params:
    print('Ad parameter with text "%s" was successfully set for criterion '
          'with id "%s" and ad group id "%s".'
          % (ad_param['insertionText'], ad_param['criterionId'],
              ad_param['adGroupId']))


if __name__ == '__main__':
  # Initialize client object.
  adwords_client = adwords.AdWordsClient.LoadFromStorage()

  main(adwords_client, AD_GROUP_ID, CRITERION_ID)
github googleads / googleads-python-lib / examples / adwords / v201710 / basic_operations / get_ad_groups.py View on Github external
# Display results.
    if 'entries' in page:
      for ad_group in page['entries']:
        print ('Ad group with name "%s", id "%s" and status "%s" was '
               'found.' % (ad_group['name'], ad_group['id'],
                           ad_group['status']))
    else:
      print 'No ad groups were found.'
    offset += PAGE_SIZE
    selector['paging']['startIndex'] = str(offset)
    more_pages = offset < int(page['totalNumEntries'])


if __name__ == '__main__':
  # Initialize client object.
  adwords_client = adwords.AdWordsClient.LoadFromStorage()

  main(adwords_client, CAMPAIGN_ID)
github googleads / googleads-python-lib / examples / adwords / v201710 / reporting / download_criteria_report_as_stream_with_awql.py View on Github external
try:
    while True:
      chunk = stream_data.read(CHUNK_SIZE)
      if not chunk: break
      report_data.write(chunk.decode() if sys.version_info[0] == 3
                        and getattr(report_data, 'mode', 'w') == 'w' else chunk)
    print report_data.getvalue()
  finally:
    report_data.close()
    stream_data.close()


if __name__ == '__main__':
  # Initialize client object.
  adwords_client = adwords.AdWordsClient.LoadFromStorage()

  main(adwords_client)
github googleads / googleads-python-lib / examples / adwords / v201609 / optimization / get_keyword_bid_simulations.py View on Github external
'points was found:'
               % (bid_landscape['adGroupId'], bid_landscape['criterionId'],
                  bid_landscape['startDate'], bid_landscape['endDate']))
        for bid_landscape_point in bid_landscape['landscapePoints']:
          print ('  bid: %s => clicks: %s, cost: %s, impressions: %s'
                 % (bid_landscape_point['bid']['microAmount'],
                    bid_landscape_point['clicks'],
                    bid_landscape_point['cost']['microAmount'],
                    bid_landscape_point['impressions']))
  else:
    print 'No bid landscapes found.'


if __name__ == '__main__':
  # Initialize client object.
  adwords_client = adwords.AdWordsClient.LoadFromStorage()

  main(adwords_client, AD_GROUP_ID, CRITERION_ID)
github googleads / googleads-python-lib / examples / adwords / v201705 / misc / upload_image.py View on Github external
media = media_service.upload(media)[0]

  # Display results.
  if media:
    dimensions = dict([(entry['key'], entry['value'])
                       for entry in media['dimensions']])
    print ('Image with id "%s", dimensions \'%sx%s\', and MimeType "%s" was'
           ' uploaded.' % (media['mediaId'], dimensions['FULL']['height'],
                           dimensions['FULL']['width'], media['mimeType']))
  else:
    print 'No images were uploaded.'


if __name__ == '__main__':
  # Initialize client object.
  adwords_client = adwords.AdWordsClient.LoadFromStorage()

  main(adwords_client, IMAGE_FILENAME)
github googleads / googleads-python-lib / examples / adwords / authentication / create_adwords_client_with_service_account.py View on Github external
def main(key_file, service_account_user, developer_token, user_agent,
         client_customer_id):
  oauth2_client = oauth2.GoogleServiceAccountClient(
      key_file, oauth2.GetAPIScope('adwords'), sub=service_account_user)

  adwords_client = adwords.AdWordsClient(
      developer_token, oauth2_client, user_agent,
      client_customer_id=client_customer_id)

  customer_service = adwords_client.GetService('CustomerService',
                                               version='v201702')
  customers = customer_service.getCustomers()

  print('You are logged in as a user with access to the following customers:')

  for customer in customers:
    print('\t%s' % customer['customerId'])
github googleads / googleads-python-lib / examples / adwords / v201609 / campaign_management / add_campaign_labels.py View on Github external
'labelId': label_id,
          }
      }
  ]

  result = campaign_service.mutateLabel(operations)

  # Display results.
  for label in result['value']:
    print ('CampaignLabel with campaignId \'%s\' and labelId \'%s\' was added.'
           % (label['campaignId'], label['labelId']))


if __name__ == '__main__':
  # Initialize client object.
  adwords_client = adwords.AdWordsClient.LoadFromStorage()

  main(adwords_client, CAMPAIGN_ID1, CAMPAIGN_ID2, LABEL_ID)
github googleads / googleads-python-lib / examples / adwords / v201506 / error_handling / handle_policy_violation_error.py View on Github external
client.validate_only = False
  if operations:
    response = ad_group_ad_service.mutate(operations)
    if response and response['value']:
      ads = response['value']
      print 'Added %s ad(s) to ad group %s.' % (len(ads), ad_group_id)
      for ad in ads:
        print ('  Ad id is %s, type is %s and status is \'%s\'.' %
               (ad['ad']['id'], ad['ad']['Ad.Type'], ad['status']))
    else:
      print 'No ads were added.'


if __name__ == '__main__':
  # Initialize client object.
  adwords_client = adwords.AdWordsClient.LoadFromStorage()

  main(adwords_client, AD_GROUP_ID)
github googleads / googleads-python-lib / examples / adwords / v201702 / campaign_management / get_campaigns_by_label.py View on Github external
if 'entries' in page:
      for campaign in page['entries']:
        print ('Campaign found with Id \'%s\', name \'%s\', and labels: %s'
               % (campaign['id'], campaign['name'], campaign['labels']))
    else:
      print 'No campaigns were found.'

    offset += PAGE_SIZE
    selector['paging']['startIndex'] = str(offset)
    more_pages = offset < int(page['totalNumEntries'])
    time.sleep(1)


if __name__ == '__main__':
  # Initialize client object.
  adwords_client = adwords.AdWordsClient.LoadFromStorage()

  main(adwords_client, LABEL_ID)