Skip to main content
Contributor I
January 15, 2024
Solved

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

  • January 15, 2024
  • 3 replies
  • 413 views

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'

 

    This topic has been closed for replies.
    Best answer by saulblum

    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.

     

     

    3 replies

    KeviSunshine
    Expert Problem Solver III
    Expert Problem Solver III
    January 15, 2024

    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.

    saulblumAnswer
    Klaviyo Employee
    January 16, 2024

    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.

     

     

    lepfsdAuthor
    Contributor I
    January 16, 2024

    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