https://github.com/ignacio-chiazzo/cursor-vs-page-pagination-in-shopify
Compare Shopify REST Admin API using Relative Cursor vs Page based pagination.
https://github.com/ignacio-chiazzo/cursor-vs-page-pagination-in-shopify
pagination pagination-links rest-api shopify shopify-api shopify-apps shopify-partners
Last synced: 6 months ago
JSON representation
Compare Shopify REST Admin API using Relative Cursor vs Page based pagination.
- Host: GitHub
- URL: https://github.com/ignacio-chiazzo/cursor-vs-page-pagination-in-shopify
- Owner: ignacio-chiazzo
- Created: 2020-03-12T19:04:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-20T22:15:55.000Z (over 2 years ago)
- Last Synced: 2025-03-30T11:02:22.138Z (6 months ago)
- Topics: pagination, pagination-links, rest-api, shopify, shopify-api, shopify-apps, shopify-partners
- Language: Ruby
- Homepage: https://ignacio-chiazzo.github.io/Shopify-Pagination-relative-cursor-vs-page
- Size: 9.75 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Shopify-Pagination-relative-cursor-vs-page
Compare Shopify REST Admin API using Relative Cursor vs Page based pagination.[Shopify Released Cursor-based pagination](https://shopify.dev/tutorials/make-paginated-requests-to-rest-admin-api) in version `2019-07`, this script compares this new approach with the old one (using page based pagination).
### Prerequisites:
You need to install the `shopify_api` gem. You can run in the console `gem install shopify_api`You need two things, a `shop` domain and an `access_token`. You can read [this doc](https://github.com/Shopify/shopify_api#3-requesting-access-from-a-shop) to see how can you generate that token.
### Getting started.
1) Go to the file `src/constants.rb` and modify the variables `DOMAIN` and `ACCESS_TOKEN`.
2) Then run the file `ruby api_pagination_benchmark.rb`.This will iterate over all sets (defined in `PaginatedModels`) twice, one using **Page based pagination** and other using **Cursor based pagination** and post some metrics. See image below:
**OR you can use the CLI** by running `ruby cli_run.rb`
### The output
### Changing params
You can change the size of the `page` by changing the variable `LIMIT_PER_PAGE` in the file `src/constants.rb`. If you want to add or modify which resources it will iterate(e.g. `Collection`, or `Order`), you need to modify the file `src/paginated_models.rb`
### Notes
Some of the endpoints are using some kind of cache so trying to run the script multiple times in a short period of time, might retrieve similar numbers. You can see a big difference in the very first run.