# How to paginate using next\_page\_token

**URL:** <https://devforum.zoom.us/t/how-to-paginate-using-next-page-token/87128>\
**Category:** Phone\
**Tags:** api\
**Created:** [April 20, 2023, 7:25pm UTC](https://devforum.zoom.us/t/how-to-paginate-using-next-page-token/87128 "2023-04-20T19:25:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![clchrist](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/clchrist/32/45224_2.png) [@clchrist](https://devforum.zoom.us/u/clchrist)\
**Post date:** [April 20, 2023, 7:25pm UTC](https://devforum.zoom.us/t/how-to-paginate-using-next-page-token/87128/1 "2023-04-20T19:25:09Z")

</div>

API Endpoint(s) and/or Zoom API Event(s): [https://api.zoom.us/v2/phone/numbers](https://api.zoom.us/v2/phone/numbers)  
[https://developers.zoom.us/docs/api/rest/reference/phone/methods/#operation/listAccountPhoneNumbers](https://developers.zoom.us/docs/api/rest/reference/phone/methods/#operation/listAccountPhoneNumbers)

I have a working API for Phone Numbers that is connecting and returning the first page of results with a next\_page\_token, page\_size, and total\_records. I have tried a few things but the next\_page\_token does not paginate through the additional pages of data. It continues returning the first page.

How is next\_page\_token used to paginate through all the pages in Python?

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [April 21, 2023, 1:03am UTC](https://devforum.zoom.us/t/how-to-paginate-using-next-page-token/87128/2 "2023-04-21T01:03:33Z")

</div>

Hi @clchrist  
Thanks for reaching out to us!  
Here is a link to a post on how to use the next\_page\_token:

> [@Handling paginated responses from the Zoom API](https://devforum.zoom.us/t/handling-paginated-responses-from-the-zoom-api/68825):
>
> When an API response contains more data than can be returned in a single page, the API will return with a token to request the next page of results. But how will you expect to receive a paginated response? If your response contains a next page token, make the same request again using that token as a query parameter. Say you have 70 users on your account, as in, more than the default page size of 30. A request to the list users will initially respond with 30 users. To get the full list, you’ll …

If this continues to be an issue that you are not getting the last page, please let me know and I can take a closer look  
Cheer,  
Elisa

---

<div class="post-metadata">

**Author:** ![charles1237718](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@charles1237718](https://devforum.zoom.us/u/charles1237718)\
**Post date:** [April 23, 2023, 3:49pm UTC](https://devforum.zoom.us/t/how-to-paginate-using-next-page-token/87128/3 "2023-04-23T15:49:46Z")

</div>

> [@clchrist](#):
>
> API Endpoint(s) and/or Zoom API Event(s): [https://api.zoom.us/v2/phone/numbers](https://api.zoom.us/v2/phone/numbers)  
> [Zoom Phone API](https://developers.zoom.us/docs/api/rest/reference/phone/methods/#operation/listAccountPhoneNumbers)
> 
> I have a working API for Phone Numbers that is connecting and returning the first page of results with a next\_page\_token, page\_size, and total\_records. I have tried a few things but the next\_page\_token does not paginate through the additional pages of data. It continues returning the first page.
> 
> How is next\_page\_token used to paginate through all the pages in Python?

To paginate through all the pages using the next\_page\_token parameter in Python, you can use a loop to make subsequent requests until all pages have been retrieved. Here is an example code snippet:

import requests

# Set up initial request parameters

url = “[https://api.zoom.us/v2/phone/numbers](https://api.zoom.us/v2/phone/numbers)”  
params = {  
“page\_size”: 50 # Set the desired page size  
}

# Make the initial request and retrieve the first page of results

response = requests.get(url, params=params)  
data = response.json()  
next\_page\_token = data.get(“next\_page\_token”)

# Loop through subsequent pages until all pages have been retrieved

while next\_page\_token:  
# Add the next\_page\_token to the request parameters  
params[“next\_page\_token”] = next\_page\_token

```
# Make the request for the next page of results

```

I hope it’ll help[.](https://theapkregion.com/gangstar-vegas-mod-apk/)

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [April 25, 2023, 6:17pm UTC](https://devforum.zoom.us/t/how-to-paginate-using-next-page-token/87128/4 "2023-04-25T18:17:56Z")

</div>

Thanks for chiming in @charles1237718

---

<div class="post-metadata">

**Author:** ![clchrist](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/clchrist/32/45224_2.png) [@clchrist](https://devforum.zoom.us/u/clchrist)\
**Post date:** [April 25, 2023, 10:03pm UTC](https://devforum.zoom.us/t/how-to-paginate-using-next-page-token/87128/5 "2023-04-25T22:03:58Z")

</div>

Thank you, Ahmed [charles1237718](https://devforum.zoom.us/u/charles1237718). Very helpful. I have tried several different similar approaches and I haven’t been able to get it working yet.

Here is my initial code retrieving the first page only (minus the writeJSONfile snip):

import requests  
import json

access\_token = “working\_token”

url = “[https://api.zoom.us/v2/phone/numbers](https://api.zoom.us/v2/phone/numbers)”

headers = {  
“Authorization”: f"Bearer {access\_token}",  
“Content-Type”: “application/json”,  
}

response = requests.get(url, headers=headers)

Could you clarify the structure including your suggestions?

Thank you!
