# Help paginating through Canvas API

**URL:** <https://community.postman.com/t/help-paginating-through-canvas-api/15597>\
**Category:** Help Hub\
**Tags:** pagination\
**Created:** [September 3, 2020, 10:45pm UTC](https://community.postman.com/t/help-paginating-through-canvas-api/15597 "2020-09-03T22:45:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![timfin321](https://avatars.discourse-cdn.com/v4/letter/t/f07891/32.png) [@timfin321](https://community.postman.com/u/timfin321)\
**Post date:** [September 3, 2020, 10:45pm UTC](https://community.postman.com/t/help-paginating-through-canvas-api/15597/1 "2020-09-03T22:45:28Z")

</div>

I have tried using pre-request scripts and other mechanisms but to no avail. This particular endpoint is created in a way so that a link header is passed back after the first call that contains this literal info:  
[https://my\_base\_url/api/v1/accounts/1/users?enrollment\_type=student&order=desc&sort=last\_login&page=1&per\_page=10](https://my_base_url/api/v1/accounts/1/users?enrollment_type=student&order=desc&sort=last_login&page=1&per_page=10); rel=“current”,

[https://my\_base\_url/api/v1/accounts/1/users?enrollment\_type=student&order=desc&sort=last\_login&page=2&per\_page=10](https://my_base_url/api/v1/accounts/1/users?enrollment_type=student&order=desc&sort=last_login&page=2&per_page=10); rel=“next”,

[https://my\_base\_url/api/v1/accounts/1/users?enrollment\_type=student&order=desc&sort=last\_login&page=1&per\_page=10](https://my_base_url/api/v1/accounts/1/users?enrollment_type=student&order=desc&sort=last_login&page=1&per_page=10); rel=“first”,

[https://my\_base\_url/api/v1/accounts/1/users?enrollment\_type=student&order=desc&sort=last\_login&page=4559&per\_page=10](https://my_base_url/api/v1/accounts/1/users?enrollment_type=student&order=desc&sort=last_login&page=4559&per_page=10); rel=“last”

you can see the relative info about the particular page you’re looking at is returned. how do I extract information from the header, which could always be different and iterate from page 1 through whatever the last page might be? I also want to collate the output into a single JSON that can be saved.

---

<div class="post-metadata">

**Author:** ![timfin321](https://avatars.discourse-cdn.com/v4/letter/t/f07891/32.png) [@timfin321](https://community.postman.com/u/timfin321)\
**Post date:** [September 3, 2020, 11:05pm UTC](https://community.postman.com/t/help-paginating-through-canvas-api/15597/2 "2020-09-03T23:05:02Z")

</div>

maybe something along the lines of setting the “page” query param to whatever the corresponding page is in the link header when “rel=“next””?
