# How should I use cursor to fetch all possible entries using REST API?

**URL:** <https://community.developer.atlassian.com/t/how-should-i-use-cursor-to-fetch-all-possible-entries-using-rest-api/81023>\
**Category:** Forge\
**Tags:** confluence-cloud, rest-api, forge\
**Created:** [June 20, 2024, 1:53pm UTC](https://community.developer.atlassian.com/t/how-should-i-use-cursor-to-fetch-all-possible-entries-using-rest-api/81023 "2024-06-20T13:53:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JunheokCheon](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@JunheokCheon](https://community.developer.atlassian.com/u/JunheokCheon)\
**Post date:** [June 20, 2024, 1:53pm UTC](https://community.developer.atlassian.com/t/how-should-i-use-cursor-to-fetch-all-possible-entries-using-rest-api/81023/1 "2024-06-20T13:53:21Z")

</div>

Hello, I have some question regards the REST api for Confluence and how ‘route’ works.

Previously I was doing something like this in order to repeatedly call REST api until it reaches end of the page:

```auto
let address = `/wiki/api/v2/spaces/${spaceId}/properties?limit=250`;
  let propertyArray = [];
  while(true){
    const getProperties = await api.asApp().requestConfluence(route (address), {
      headers: {
        'Accept': 'application/json'
      }
    });
    const propertyReturn = await getProperties.json();

    propertyArray = propertyArray.concat(propertyReturn.results);
    if(propertyReturn._links.next == undefined || propertyReturn._links.next == null){ 
      break;
    }
    //set address to cursor
    address = propertyReturn._links.next;
  }

```

So basically, I had a variable that contains the REST API address, and I update it to cursor and call it again until there is no more cursor. However, recently, Atlassian team has update so that you can no longer do:

```auto
route (address)

```

For now, I just have a single REST API call, without having any address variable. I need a way to repeatedly call REST API until there is no more entries. Is there any idea about how to do this with current route changes?

---

<div class="post-metadata">

**Author:** ![AaronCollier](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@AaronCollier](https://community.developer.atlassian.com/u/AaronCollier)\
**Post date:** [June 21, 2024, 8:15am UTC](https://community.developer.atlassian.com/t/how-should-i-use-cursor-to-fetch-all-possible-entries-using-rest-api/81023/2 "2024-06-21T08:15:06Z")

</div>

If you know the route will be OK, you can use `assumeTrustedRoute` in place of `route` from `@forge/api`. Just make sure there’s no chance the route will include user input or anything.

---

<div class="post-metadata">

**Author:** ![JunheokCheon](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@JunheokCheon](https://community.developer.atlassian.com/u/JunheokCheon)\
**Post date:** [June 24, 2024, 10:53am UTC](https://community.developer.atlassian.com/t/how-should-i-use-cursor-to-fetch-all-possible-entries-using-rest-api/81023/3 "2024-06-24T10:53:53Z")

</div>

Thanks for the reply,

This worked for me, so I will set it as a solution.

Also, how did you find about this?

---

<div class="post-metadata">

**Author:** ![AaronCollier](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@AaronCollier](https://community.developer.atlassian.com/u/AaronCollier)\
**Post date:** [June 24, 2024, 1:16pm UTC](https://community.developer.atlassian.com/t/how-should-i-use-cursor-to-fetch-all-possible-entries-using-rest-api/81023/4 "2024-06-24T13:16:02Z")

</div>

I ran into a similar problem a while ago. I think I got it from [the documentation](https://developer.atlassian.com/platform/forge/apis-reference/fetch-api-product.requestconfluence/#usage).
