Solved

help listing profiles with cursor[page] and cursor[size]

  • 15 January 2024
  • 3 replies
  • 88 views

Badge

I try to list the profiles with pagination and limit, the cursor parameter is string which should be 1, 2, 3 and I can't get a correct example to be able to list the profiles

Can someone give me an example of how to list profiles?

 

curl --request GET \
     --url 'https://a.klaviyo.com/api/profiles/?page[cursor]=1&page[size]=1' \
     --header 'accept: application/json' \
     --header 'revision: 2023-12-15'

 

icon

Best answer by saulblum 16 January 2024, 15:01

View original

3 replies

Userlevel 4
Badge +7

Hi @lepfsd,

The page[cursor] argument is not an integer for Klaviyo–it’s a guid. The API is “self-discoverable” meaning you need to use the cursor guids returned in the `links` object from the API. You’ll see the response has a `links` object that will look something like this:

 "links": {
"self": "https://a.klaviyo.com/api/segments/RwG4Rh/profiles/?page[size]=100&page[cursor]=",
"next": "https://a.klaviyo.com/api/segments/RwG4Rh/profiles/?page%5Bsize%5D=100&page%5Bcursor%5D=bmV4dDo6aWQ6OgApMzQ2NTE5NjI0OA",
"prev": null
}

Use the `links.next` URL to get the next page.

In this example, the value of page[“cursor”] is “bmV4dDo6aWQ6OgApMzQ2NTE5NjI0OA.”

 

Cheers,

Kevin.

Userlevel 5
Badge +7

At the end of the response you should see something like:

    "links": {

        "self": "https://a.klaviyo.com/api/profiles/",

        "next": "https://a.klaviyo.com/api/profiles/?page%5Bcursor%5D=bmV4dDo6aWQ6OjAxRzFNOFFRVjZWRjI4Q0VOVjBYMTNCUFI4",

        "prev": null

    }

In this case, the page[cursor] param would be bmV4dDo6aWQ6OjAxRzFNOFFRVjZWRjI4Q0VOVjBYMTNCUFI4

It’s not a numeric index, but a string returned in the response.

 

 

Badge

At the end of the response you should see something like:

    "links": {         "self": "https://a.klaviyo.com/api/profiles/",         "next": "https://a.klaviyo.com/api/profiles/?page%5Bcursor%5D=bmV4dDo6aWQ6OjAxRzFNOFFRVjZWRjI4Q0VOVjBYMTNCUFI4",         "prev": null     }

In this case, the page[cursor] param would be bmV4dDo6aWQ6OjAxRzFNOFFRVjZWRjI4Q0VOVjBYMTNCUFI4

It’s not a numeric index, but a string returned in the response.

 

 

thanks 

Reply