Hello everyone,
I recently started seeing an error while trying to use the AdGroupService
API to pull the current CPC bids for adgroups in one of my accounts.
This is the code I have been using to do this:
client.SetClientCustomerId(str(account_id))
ad_group_service = client.GetService('AdGroupService', version='v201605')
PAGE_SIZE = 500
# Get all ad group bid
selector = {
'fields': ['CampaignId', 'CampaignName', 'Id', 'Name', 'CpcBid'],
'predicates': [
{
'field': 'Status',
'operator': 'EQUALS',
'values': 'ENABLED'
}
],
'paging': {
'startIndex': '0',
'numberResults': '500'
}
}
# Set initial values.
offset, page = 0, {}
more_results = True
bids = []
number = 0
while more_results:
page = ad_group_service.get(selector)
if not bids:
print('total number of entries: %s' % int(page['totalNumEntries']))
if page['entries']:
for bid in page['entries']:
current_bid = bid.biddingStrategyConfiguration.bids[0].bid[1]
bid_dict = {'CampaignId': bid['campaignId'],
'AdGroupId': bid['id'],
'CurrentBid': current_bid if current_bid else 0}
number += 1
print('bid number %s' % number)
print(bid_dict)
bids.append(bid_dict)
# Increment values to request the next page.
offset += PAGE_SIZE
selector['paging']['startIndex'] = str(offset)
else:
print('No ad group bid modifiers returned.')
more_results = int(page['totalNumEntries']) > offset
dataframe = pd.DataFrame(bids)
return dataframe
However, the Client Account only contains ~25,000 adgroups but the API is
returning a total of ~116,000 adgroups.
I am not sure why the query is returning this large amount of
campaign/adgroups. Is there something I am missing?
Thanks,
Alex
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
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/1e9cd6c8-63b3-46fe-a5d4-e3a1bd44d226%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.