I am trying to get all order events for a shop for my shopify app. What would be the best scalable way?
I have tried Events API, the documentation for Events API says to use GET /admin/events.json
to retrieve a list of all events for a shop, but it doesn’t return all order events, only order confirmed event is returned.
The way I can see all events associated with an order is by using GET /admin/orders/#{order_id}/events.json
, but this solution might not work for my use case. With this endpoint, i will need to get list of all orders first and then iterate over those order IDs to get events for those orders. It’s won’t be scalable for me at order ID level, it would perfect if i can get all order events though one endpoint at the events level.
Does anyone know the best way to solve this issue?
2
Answers
There is a way. I would do this:
Now when ever your merchant customer wants to see the events associated with an order and it would be inconvenient of them to just navigate to the order, a call to your App with the Order ID can snappily report the events as you saved them.
If you listen to order updates, you could scan for new events added.
So your scaling problem is not really a problem since you need only grab old orders once. Moving forward just listening to orders/update will keep things updated without a whole lot of overhead.
If you specifically are looking for Order timeline events, you can get this using the Shopify GraphQL Admin API. A query like this will return the first 100 events on a specific order.
This will return a result like