GET /api/product_inventory/ _very_ slow

in Development
Hi folks. Most other things return at fairly reasonably speeds. Things like GET /api/products returns approx 25k products in ~10 seconds. But when calling GET /api/product_inventory/ on the same server and data set I'm seeing more like 8-10 minutes.
Is this expected or is something not indexed that should be? This seems like something might be wrong behind the scenes so wanted to check in.
Is this expected or is something not indexed that should be? This seems like something might be wrong behind the scenes so wanted to check in.
10 comments
I ran some tests on different databases, and the product_invenotory call is consistently much longer. The call is just a lot more intensive.
I'd recommend breaking the call into multiple pages:
Lightspeed HQ
At that point instead of having to do guesswork and manage thousands of calls I'll just stick with 12 and take the medicine and wait 10 minutes per call and hope they don't time out too often.
It really does sound like something on the backend is not indexed that should be IMHO.
Do you need to pull all products from product_inventory on a regular basis? If you want to look for changes to inventory, you can use the /api/products/search/ endpoint and filter by inventory_version. The inventory_version is a sequence that's incremented with every inventory change in the OnSite database. The product whose inventory version changed is assigned the current value of the sequence.
To use this, keep track of the highest inventory version value that you've seen on your end. Then when you want to check for inventory changes, you just have to find all products whose inventory version is higher than that number.
The filter in your search payload would look like this:
Where you would replace 220 with the last value you have saved.
The product search endpoint is explained more in this tutorial:
https://www.lightspeedhq.com/onsite-docs/external_api/tutorials/products.html#search-by-description
I'll bring up the response time with the Development team. I think you are right that there's no reason it should be that much longer.
Lightspeed HQ
I'm happy to work with anyone on the dev team if desired as well, ping me anytime and thanks for forwarding this along to them.
Am I understanding correctly? If so then this would likely be pretty useful for us (but I will have to rework a bunch of code to make it happen).
There's also a `created_date` filter that you can use to get newly created products.
You can combine multiple filters:
Lightspeed HQ
Lightspeed HQ
Makes me a bit nervous to run deltas like this though as it doesn't seem like I have any way to reference any information about the details of the last inventory_version to find out when it happened. Am I correct in assuming there's no way to check an inventory_version from the API to see when it occurred?
Lightspeed HQ