Re: Google Ads API Extremely Slow
+1. Slower then XML AdWords API. -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. Visit this group at https://groups.google.com/group/adwords-api. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/fe61a067-77e8-4131-bf82-87645620e27b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
RE: Google Ads API Extremely Slow
Hi, Can you please provide your API request and response so I can see if there are any issues through *reply privately to author*? Thanks, Anthony Google Ads API Team =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: https://ads-developers.googleblog.com/search/label/google_ads_api https://developers.google.com/adwords/api/community/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ On 04/18/19 03:40:21 dajkata...@gmail.com wrote: I am using the google ads api for keyword research on my website but it takes too long. Simply getting the data from the google database takes 6 seconds. I have removed anything that modifies the data so I am sure that it takes 6 seconds to get the data. This is the code for getting the keyword volume, competition and ideas. import csv import time import suds import re from googleads import adwords import os class Ads(object): def __init__(self, keywords): self.num_calls = 0 self.langID = 1000 self.locID = 2840 self.adwords_client = adwords.AdWordsClient.LoadFromStorage('googleads.yaml') self.before_estimate = keywords # set up queries for search volume list_of_calls = [self.before_estimate[i:i + 200] for i in range(0, len(self.before_estimate), 200)] self.num_calls = len(list_of_calls) print("Get ready for ", self.num_calls, "calls and approximately ", self.num_calls * 50, "seconds.") self.results = self.get_estimate_search_volume(list_of_calls) def api_call_function(self, keyword_list, langID, locID, count, requestType): targeting_idea_service = self.adwords_client.GetService('TargetingIdeaService', version='v201809') offset = 0 PAGE_SIZE = 100 selector = { 'searchParameters': [ { 'xsi_type': 'RelatedToQuerySearchParameter', 'queries': keyword_list }, { 'xsi_type': 'LanguageSearchParameter', 'languages': [{'id': langID}] }, { 'xsi_type': 'LocationSearchParameter', 'locations': [{'id': locID}] }, { # Network search parameter (optional) 'xsi_type': 'NetworkSearchParameter', 'networkSetting': { 'targetGoogleSearch': True, 'targetSearchNetwork': False, 'targetContentNetwork': False, 'targetPartnerSearchNetwork': False } }, { 'xsi_type': 'IdeaTextFilterSearchParameter', 'included': keyword_list } ], 'ideaType': 'KEYWORD', 'requestType': requestType, 'requestedAttributeTypes': ['KEYWORD_TEXT', 'SEARCH_VOLUME', 'COMPETITION'], 'paging': { 'startIndex': str(offset), 'numberResults': count } } page = targeting_idea_service.get(selector) # Create dictionary with keyword, search volume pair all_results = {} for result in page['entries']: for attribute in result['data']: if attribute['key'] == "KEYWORD_TEXT": word = attribute['value']['value'] if attribute['key'] == "SEARCH_VOLUME": volume = attribute['value']['value'] if attribute['key'] == "COMPETITION": competition = attribute['value']['value'] if competition == 0.0 or competition is None: pass else: all_results[word] = [volume, competition] return all_results def api_call_error_handling(self, errors, current_call, i): def save_and_delete_keywords(keyword_file, error_lines): # delete bad keywords and log those deleted deleted_keyword_file = "deleted_" + keyword_file deleted_list = [] with open(deleted_keyword_file, "a") as d_file: for bad_words in error_lines: deleted = current_call -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. Visit this group at https://groups.google.com/group/adwords-api. To view this discussion on the web visit https:/
Google Ads API Extremely Slow
I am using the google ads api for keyword research on my website but it takes too long. Simply getting the data from the google database takes 6 seconds. I have removed anything that modifies the data so I am sure that it takes 6 seconds to get the data. This is the code for getting the keyword volume, competition and ideas. import csv import time import suds import re from googleads import adwords import os class Ads(object): def __init__(self, keywords): self.num_calls = 0 self.langID = 1000 self.locID = 2840 self.adwords_client = adwords.AdWordsClient.LoadFromStorage('googleads.yaml') self.before_estimate = keywords # set up queries for search volume list_of_calls = [self.before_estimate[i:i + 200] for i in range(0, len(self.before_estimate), 200)] self.num_calls = len(list_of_calls) print("Get ready for ", self.num_calls, "calls and approximately ", self.num_calls * 50, "seconds.") self.results = self.get_estimate_search_volume(list_of_calls) def api_call_function(self, keyword_list, langID, locID, count, requestType): targeting_idea_service = self.adwords_client.GetService('TargetingIdeaService', version='v201809') offset = 0 PAGE_SIZE = 100 selector = { 'searchParameters': [ { 'xsi_type': 'RelatedToQuerySearchParameter', 'queries': keyword_list }, { 'xsi_type': 'LanguageSearchParameter', 'languages': [{'id': langID}] }, { 'xsi_type': 'LocationSearchParameter', 'locations': [{'id': locID}] }, { # Network search parameter (optional) 'xsi_type': 'NetworkSearchParameter', 'networkSetting': { 'targetGoogleSearch': True, 'targetSearchNetwork': False, 'targetContentNetwork': False, 'targetPartnerSearchNetwork': False } }, { 'xsi_type': 'IdeaTextFilterSearchParameter', 'included': keyword_list } ], 'ideaType': 'KEYWORD', 'requestType': requestType, 'requestedAttributeTypes': ['KEYWORD_TEXT', 'SEARCH_VOLUME', 'COMPETITION'], 'paging': { 'startIndex': str(offset), 'numberResults': count } } page = targeting_idea_service.get(selector) # Create dictionary with keyword, search volume pair all_results = {} for result in page['entries']: for attribute in result['data']: if attribute['key'] == "KEYWORD_TEXT": word = attribute['value']['value'] if attribute['key'] == "SEARCH_VOLUME": volume = attribute['value']['value'] if attribute['key'] == "COMPETITION": competition = attribute['value']['value'] if competition == 0.0 or competition is None: pass else: all_results[word] = [volume, competition] return all_results def api_call_error_handling(self, errors, current_call, i): def save_and_delete_keywords(keyword_file, error_lines): # delete bad keywords and log those deleted deleted_keyword_file = "deleted_" + keyword_file deleted_list = [] with open(deleted_keyword_file, "a") as d_file: for bad_words in error_lines: deleted = current_call.pop(bad_words) deleted_list.append(deleted) for deleted in deleted_list: d_file.write(deleted + "\n") errors = str(errors) # log errors to file with open("duplicate_error.txt", "a") as d_file: entry = "ERROR - CALL # " + str(i + 1) + "\n" d_file.write(entry) d_file.write(errors + "\n") # get line numbers from error reading error_lines = re.findall('\d\d*', errors) # clean "1" error_lines[:] = [int(x) for x in error_lines if len(x) != 1] error_lines.sort() error_lines.reverse() print(error_lines) save_and_delete_keywords(keyword_file, error_lines) return current_call def get_estimate_search_volume(self, list_of_calls): # Run estimate_search_volume for each set and add to result dictionary each time results = {} i = 0 retry = False errors = "none" while i < self.num_calls: if not retry: current_call = list_of_calls[i] try: call_results = self.api_call_function(current_call, self.langID, self.locID, 800, 'IDEAS') call_results.update(self.api_call_function(current_call, self.langID, self.locID, 800, 'STATS')) print("CALL #", i + 1, "COMPLETED.") results.update(call_results) i += 1 #time.sleep(10)