1
0
-1

Hi,

Does your server use a pagination strategy for the HTTP JSON API fetching of data?  I don't want to fetch all records at once because it would obviously slow down the response time especially if there's hundreds of records. For example, searching for all adoptable dogs in Atlanta (25 mile radius) shows over 2,575 on a popular animal search website so I'm assuming the number I get from your server will be similar to that.  I see that I can set the "resultLimit" and "resultStart."  If I set resultLimit to 25 and there's really 2,000+ records from my search query, how do I get the remaining 1,975 records to show up in my list?  I would obviously have to do subsequent pulls of small batches, probably 25 each.  Please also explain what the resultStart field is used for.  I currently have it set at 0, because I'm assuming that's page 1.  This might answer the pagination question.  Do I have to do additional fetches and change the resultStart?  Please explain how I can address this issue. I hope my question makes sense.  Thank you.

Here's some information about pagination that I found on jsonapi.org.

Note: JSON API is agnostic about the pagination strategy used by a server. Effective pagination strategies include (but are not limited to): page-based, offset-based, and cursor-based. The pagequery parameter can be used as a basis for any of these strategies. For example, a page-based strategy might use query parameters such as page[number] and page[size], an offset-based strategy might use page[offset] and page[limit], while a cursor-based strategy might use page[cursor].

Note: The example query parameters above use unencoded [ and ] characters simply for readability. In practice, these characters must be percent-encoded, per the requirements in RFC 3986.

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      Hi Angelina,

      If you are looking how to do paging with our API, you can view our article here:

      How to make a request to the HTTP API

      Under the example:  

      Example of a search (using an API key)

      you should be able to see how that is done.

       

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi Andie,

        I made the request, but just need clarification on the pagination.  For example, if I set the resultLimit to 20, then that's only going to bring in 20 records.  But, if you do a search for the Atlanta zip code using another search engine, you'll see there's really 2,000+ records of animals within that zip code.  So, even though I pulled in 20 records in my search, I need to get the other 1,980 records.  That's what I need the API pagination information for.

        Could you imagine if I searched for 3000 records all at once? It would slow things down and take forever to load. That's where pagination comes in.  I need to know what pagination scheme your API offers to it's users so that I can go to the "next" page of results and so on.  A lot of API's have detailed information about their pagination, but some don't, which may be the case here.

        I'm sure you've seen people have a link that says, "Load more" at the bottom of the first 20 so when you click it, it takes you to the next 20, and then when you get past those 20 and click "Load more," it'll load up the next 20 items.  In order to do this, I need to understand the pagination that the API uses if it does at all.  Does that make sense?  If there's no info on it, then I'm going to have to figure out how to do this without it.  Scenario B - see below.

        Scenario B - When I'm doing a search, what is the "resultStart" field used for?  That may be my answer.  When I run my first search, it says:

        "resultLimit": "25",

        "resultStart": "0"

         What does the "resultStart" mean and what does the value of zero mean.  If I wanted to get the next page of 25 items would I increment "resultStart?"

         

        Angelina

          CommentAdd your comment...