Api.jotform.com: Offset is not working

  • VKB_Corporation
    Asked on April 17, 2024 at 4:33 PM

    Hi.

    When we make a request to api.jotform.com

    to get submissions of a form, by default response is limited to 20 results.

    GET https://api.jotform.com/form/xx/submissions?apiKey=xx

    {
        "responseCode": 200,
        "message": "success",
        "content": [...
    ],
        "duration": "115.57ms",
        "resultSet": {
            "offset": 0,
            "limit": 20,
            "count": 20
        },
        "limit-left": 99977
    }


    We need to get more results, so we set limit parameter to 1000

    GET https://api.jotform.com/form/xx/submissions?apiKey=xx&limit=1000

    and it works as needed.

    {
        "responseCode": 200,
        "message": "success",
        "content": [
    ],
        "duration": "2797.39ms",
        "resultSet": {
            "offset": 0,
            "limit": 1000,
            "count": 1000
        },
        "limit-left": 99976
    }


    Now we want to get next page by setting offset to 1

    GET https://api.jotform.com/form/xx/submissions?apiKey=xx&limit=1000&offset=1

    It does not work as needed. It again returns 1000 results but only 20 results are offseted.


    For example we have a form which has total 1203 submissions.

    when we request by default it returns 0..19 results (20 results)

    when limit=1000 it returns latest 0..999 results (1000 results)

    when limit=1000 and offset=1 it returns latest 20..1019 (1000 results) <-- wrong result

    BUT it should be 1000..1202 ( 203 results for second page)

    OFFSET not working properly. It only works for default 20 results per request.

    Please help

  • Afzal JotForm Support
    Replied on April 17, 2024 at 5:21 PM

    Hi VKB_Corporation,

    Thanks for reaching out to Jotform Support. It seems there might be a misunderstanding about how the offset parameter works. The offset parameter is intended to specify the starting point of the query relative to the total number of submissions, not the page number. Therefore, if you have 1203 submissions and you set the limit to 1000, to retrieve the remaining submissions, your offset should be set to 1000, not 1. Here's how you can modify your API call to get the next set of submissions:

    GET https://api.jotform.com/form/xx/submissions?apiKey=xx&limit=1000&offset=1000

    This should return submissions from 1000 to 1202, which are the remaining submissions after the first 1000. Please note that the maximum number of submissions you can retrieve per request is 1000. If you have more than 2000 submissions, you would need to make another call with the offset set to 2000 to get the next set of results.

    Please give it a try and let us know how it goes. 

  • VKB_Corporation
    Replied on April 17, 2024 at 5:31 PM

    I see.

    Before my message to support, I have checked many variants. Seems like did not check correctly.
    Now I have checked and understood.

    Thank you very much for your support.


 
Your Answer