Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MAX_PAGE_SIZE = 10
MAX_RESULT = 20
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.')
break
for product in products:
print('Product "%s" with title "%s" was found.' %
(product['id'], product['title']))
count = count -1
if count == 0:
break
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