Google Ads API: how to use paging (page_token / next_page_token) - Python

2,625 views
Skip to first unread message

Mat

unread,
May 3, 2019, 2:18:55 AM5/3/19
to AdWords API and Google Ads API Forum
Hi,

In the examples you provide e.g. here:


... you use "page_size=page_size" but unlike the examples in the AdWords API, the examples in the Google Ads API are lacking the actual paging.

You state "To retrieve the next one thousand rows, simply send the request again, but update the request's page_token to the response's next_page_token."

... but you don't specify how to get the "next_page_token".

So: Could you please provide an example in Python on how to use paging through large search responses.

Regards
Mat


cv

unread,
May 3, 2019, 2:34:22 AM5/3/19
to AdWords API and Google Ads API Forum
Hi,

May be this PHP issue tracker may help.


Thanks,

Mat

unread,
May 3, 2019, 5:20:06 AM5/3/19
to AdWords API and Google Ads API Forum
Hi cv,

yes, that's what I'm looking for. Unfortunately, I'm not able to translate the php-code provided there to work with the python library.
Any help on that?

Regards
Mat

ll...@horizonmedia.com

unread,
May 3, 2019, 11:26:32 AM5/3/19
to AdWords API and Google Ads API Forum
If you're using the Python client library, the requests automatically sends another request if there was a next page token detected.

Which threw me off at first because I was trying to search for the token and submit the additional requests on my own.

Leon

googleadsapi...@google.com

unread,
May 3, 2019, 3:27:23 PM5/3/19
to adwor...@googlegroups.com
Hello Mat,

Thank you for the additional input. Pagination is handled automatically by the response iterator. Please check this related issue on the issue tracker as a reference. 

Regards,
Bharani, 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/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

Mat

unread,
May 6, 2019, 5:08:30 AM5/6/19
to AdWords API and Google Ads API Forum
Hi Leon and Bharani,

that's great. Thank you. 
Please consider amending the guide on this point.

Regards
Mat
Reply all
Reply to author
Forward
0 new messages