You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently this API implementation does not offer a pagination feature. https://woocommerce.github.io/woocommerce-rest-api-docs/#pagination
Would it be possible to perform pagination inside your API class? - And recursively perform the requests until the last page is received?
The text was updated successfully, but these errors were encountered:
geri777
changed the title
Pagination not supported
Pagination support
Mar 4, 2023
I just needed this and a wrote a little pagination inside a product fetch function:
defall_products(wcapi):
r=wcapi.get("products")
ifr.status_code!=200:
print("error fetching products")
return# create list with first page resultsproducts=r.json()
# paginationwhile'next'inr.linksandr.status_code==200:
r=wcapi.get(r.links['next']['url'].split("wp-json/wc/v3/")[1])
products+=r.json()
ifr.status_code>200:
print(f"Got an unexpected http response: {r.status_code}, returning what I can...")
returnproducts
Use it for inspiration maybe someone want to implement this into the package as a wrapper.
Explanation:
The requests object returned from wcapi.get has a links object which represents the Link return header and the named links that were in there.
The links object is an empty dict if there are no link headers defined.
Currently this API implementation does not offer a pagination feature.
https://woocommerce.github.io/woocommerce-rest-api-docs/#pagination
Would it be possible to perform pagination inside your API class? - And recursively perform the requests until the last page is received?
The text was updated successfully, but these errors were encountered: