# Fetch pagination

**URL:** <https://www.patreondevelopers.com/t/fetch-pagination/4839>\
**Category:** Uncategorized\
**Created:** [October 18, 2021, 10:06am UTC](https://www.patreondevelopers.com/t/fetch-pagination/4839 "2021-10-18T10:06:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gwood](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@gwood](https://www.patreondevelopers.com/u/gwood)\
**Post date:** [October 18, 2021, 10:06am UTC](https://www.patreondevelopers.com/t/fetch-pagination/4839/1 "2021-10-18T10:06:17Z")

</div>

I use `fetch_page_of_members_from_campaign()` in the PHP library.

In this function, we have:

`$url = "campaigns/{$campaign_id}/members?page%5Bsize%5D={$page_size}";`

But when I set the `size` to move than 500, then it takes endless of time to get the data (more than 5 minutes). My question is, how can I set `size` to `100` and then **paginate** through the pages? Meaning separate the fetching into multiple calls.

For example:

Request one gets 1-100 entries. Request two gets 101-200 entries. Do you get what I mean?

I am certain there is a way to paginate it? Does the API docs offer a solution?

---

<div class="post-metadata">

**Author:** ![Zanaras](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/zanaras/32/1792_2.png) [@Zanaras](https://www.patreondevelopers.com/u/Zanaras)\
**Post date:** [October 18, 2021, 11:10pm UTC](https://www.patreondevelopers.com/t/fetch-pagination/4839/2 "2021-10-18T23:10:46Z")

</div>

[API Reference](https://docs.patreon.com/#pagination-and-sorting) Is what you’re looking for.

Your $url would end uplooking something like: `campaigns/{$campaign_id}/members?page%5Bcount%5D={$page_size}&sort=pledge_relationship_start&page%5Bcursor%5D={$start_date}` which would return the members of your campaign in ascending order with the oldest member on or after the start date first. You will want to `urlencode($start_date)` before building that url, as well.

Since the PHP Patreon package is a bit iffy on what it supports (page size vs page count, for instance), you’ll probably want to bypass `fetch_page_of_members_from_campaign` and just pass the URL suffix to `get_data` directly.
