Skip to content

Instantly share code, notes, and snippets.

Created April 27, 2019 02:15
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hamletbatista/96ab561758668a696b67939e221e8653 to your computer and use it in GitHub Desktop.
merchant_id = XXXXXXX
#execute list API
request = service.products().list(
merchantId=merchant_id, maxResults=MAX_PAGE_SIZE)
#iterate over results and stop at MAX_RESULT products
count = MAX_RESULT
while request is not None and count > 0:
result = request.execute()
products = result.get('resources')
if not products:
print('No products were found.')
for product in products:
print('Product "%s" with title "%s" was found.' %
(product['id'], product['title']))
count = count -1
if count == 0:
request = service.products().list_next(request, result)
#example output
#Product "online:en:US:XX-XXXXX-XX" with title "Produc Title 1" was found.
#Product "online:en:US:XX-XXX-XX-XX" with title "Produc Title 2" was found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment