Compare Shopify REST Admin API using Relative Cursor vs Page based pagination.
Shopify Released Cursor-based pagination in version 2019-07
, this script compares this new approach with the old one (using page based pagination).
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 to see how can you generate that token.
- Go to the file
src/constants.rb
and modify the variablesDOMAIN
andACCESS_TOKEN
. - 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
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
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.