-
Hi everyone, When I try to get inventory report, it exports 50 items only. Reading sp-api docs, I see something about pagination for traffic control, but I don't know how to iterate through pages in order to get inventory for all items. Appreciate your help.
|
Beta Was this translation helpful? Give feedback.
Answered by
yberezkin
May 26, 2021
Replies: 1 comment 2 replies
-
Hey, @ej-codex - not sure you looking exactly for that - but this is my own usage of that endpoint with pagination. If you have any questions - don't hesitate to ask. fba_inventory = []
count = 1
print('get_inventory_summary_marketplace: ', count)
response = Inventories(credentials=credentials).get_inventory_summary_marketplace(details=True)
fba_inventory.extend(each for each in response.payload.get('inventorySummaries', []))
next_token = response.pagination.get('nextToken', None)
while next_token:
count += 1
print('get_inventory_summary_marketplace: ', count)
response = Inventories(credentials=credentials).get_inventory_summary_marketplace(nextToken=next_token, details=True)
fba_inventory.extend(each for each in resp.payload.get('inventorySummaries', []))
next_token = response.pagination.get('nextToken', None) if response.pagination else None
inventory = [parse_inv_item(item) for item in fba_inventory]
inventory.sort(key=lambda x: x['sellerSku']) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
saleweaver
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, @ej-codex - not sure you looking exactly for that - but this is my own usage of that endpoint with pagination. If you have any questions - don't hesitate to ask.