# Okta Paging and the Next Link

**URL:** <https://devforum.okta.com/t/okta-paging-and-the-next-link/3391>\
**Category:** Questions\
**Created:** [November 18, 2018, 1:25am UTC](https://devforum.okta.com/t/okta-paging-and-the-next-link/3391 "2018-11-18T01:25:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ODeveloperGuy](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@ODeveloperGuy](https://devforum.okta.com/u/ODeveloperGuy)\
**Post date:** [November 18, 2018, 1:25am UTC](https://devforum.okta.com/t/okta-paging-and-the-next-link/3391/1 "2018-11-18T01:25:33Z")

</div>

Hi,

I have a question in regard to Okta paging. We want to implement a custom paging solution in Java using page and page size. Has anyone implemented something similiar and if so how have you done it? When we do a query with limit we get a next link:

“next”: {  
“href”: “[http://localhost:8080/users?after=200uh8ttBixyDwxA2g0h8&limit=14](http://localhost:8080/users?after=200uh8ttBixyDwxA2g0h8&limit=14)”  
}

From what I understand the after contains a cursor to the next page of data. What if I want to ask for page 5 with a size of 10. Is there a way to accomplish that? Also does this cursor expire? If so how long does the cursor last for? I.E. what is the precise expiration time? Is there way I can query and just get the cursors(I.E. just cursors and not pull all of the data)?

Any help you can please give would be greatly appreciated. Thank you.

---

<div class="post-metadata">

**Author:** ![micah.silverman](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/micah.silverman/32/1239_2.png) [@micah.silverman](https://devforum.okta.com/u/micah.silverman)\
**Post date:** [November 18, 2018, 1:51am UTC](https://devforum.okta.com/t/okta-paging-and-the-next-link/3391/2 "2018-11-18T01:51:50Z")

</div>

Per [https://developer.okta.com/docs/api/getting\_started/design\_principles#pagination](https://developer.okta.com/docs/api/getting_started/design_principles#pagination), the cursor is always opaque.

Also, importantly: you must use the `Link` headers in the response to page around.

You use the `limit` query parameter to specify the page size (default is 100, max is 200).

So, you could use `/api/v1/users?limit=50` to get back the first page. In the response, you would inspect the `Link` headers to get the link for the next page of data.

Here’s another reference on the `Link` header: [https://developer.okta.com/docs/api/getting\_started/design\_principles#link-header](https://developer.okta.com/docs/api/getting_started/design_principles#link-header)

HTH!

---

<div class="post-metadata">

**Author:** ![ODeveloperGuy](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@ODeveloperGuy](https://devforum.okta.com/u/ODeveloperGuy)\
**Post date:** [November 18, 2018, 12:13pm UTC](https://devforum.okta.com/t/okta-paging-and-the-next-link/3391/3 "2018-11-18T12:13:13Z")

</div>

Hi,

Thank you for the information. Do link headers or links in the response expire. I.E. is there a time limit to when they can be used in a call. For instance If I receive a Next Link like:

“next”: {  
“href”: “[http://localhost:8080/users?after=200uh8ttBixyDwxA2g0h8&limit=14”](http://localhost:8080/users?after=200uh8ttBixyDwxA2g0h8&limit=14%E2%80%9D)  
}

and I use the link [http://localhost:8080/users?after=200uh8ttBixyDwxA2g0h8&limit=14](http://localhost:8080/users?after=200uh8ttBixyDwxA2g0h8&limit=14) to get the next page can I use this link at any time or will it expire at some point? If it will expire when will that be I.E. in an hour, two hours, a day, a week? Is there a setting in Okta for this expiration? Please let me know the answer to these questions. Thank you.

---

<div class="post-metadata">

**Author:** ![RamaraoOkta](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/ramaraookta/32/1966_2.png) [@RamaraoOkta](https://devforum.okta.com/u/RamaraoOkta)\
**Post date:** [July 7, 2020, 5:53pm UTC](https://devforum.okta.com/t/okta-paging-and-the-next-link/3391/4 "2020-07-07T17:53:38Z")

</div>

I had hard time figuring out this pagination thing, so thought of contributing to this page so it helps others!!.  
My requirement was to search users with a specific search query like below

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/0/0d68b0d3d657bd127a05a5d317b29753ddf686bb.png)  
I get the results in the postman body. How do I know if I got all the users with that specific search criteria? Well you have to take a look at the response headers. If you see only one link header as “self” then thats the end of the page. There are no more records in that Okta API.  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/6/647d8c79d5da99b8be7e56ef7eb70bc5d09e63f4.png)

If there are more pages (more records), you will see two link headers

1. rel=“self”
2. rel=“next”  
Also notice “after” in the second (next) link header (below screen shot). That is what you have to follow in the next API query until you reach the end of the page, i,e until there is no more rel=“next” in the response headers!!!  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/2/26b992335d78c530900e4d8ec378d056b8401c4e.png)

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/e/eee571742dcc16583d1dcd159576e1fe7b746a18.png)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 24, 2024, 8:17pm UTC](https://devforum.okta.com/t/okta-paging-and-the-next-link/3391/5 "2024-01-24T20:17:25Z")

</div>

Closed on January 24, 2024, 8:17pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
