Open APIs

 View Only
  • 1.  Correct implementation offset and limit for paging

    TM Forum Member
    Posted Mar 04, 2021 11:58

    Hello Community,
    maybe the question is completely stupid, but I just want to make sure I understood the offset correctly.

    Suppose I have a TMF OpenAPI with a resource collection like this:

    [
      {
        "id": 10
      },
        {
        "id": 20
      },
        {
        "id": 30
      },
        {
        "id": 40
      },
        {
        "id": 50
      }
    ]


    When an API consumer calls GET /api/entities?limit=2 in the first step. Then I would expect the following response:

    [
      {
        "id": 10
      },
      {
        "id": 20
      }
    ]


    What would the next call have to look like to receive the following ressources? GET /api/entities?limit=2&offset=2 or GET /api/entities?limit=2&offset=3

    [
      {
        "id": 30
      },
      {
        "id": 40
      }
    ]
    Would be great if someone can enlight me. I think table 2 on page 42 inside the API Guidelines caused my confusion.
    Thanks and regards,
    Jan


    ------------------------------
    Jan Lemmermann
    OSS Lead Architect
    EWE TEL GmbH
    ------------------------------


  • 2.  RE: Correct implementation offset and limit for paging

    TM Forum Member
    Posted Mar 05, 2021 02:43
    Hi Jan,
    There can be no stupid question.
    In the depicted scenario to access second chunk of 2 entries, request should look like:
    GET /api/entities?offset=2&limit=2
    meaning the ask is to collect up to 2 entries, starting from index 2 included (index of very first item being 0).
    Basically browsing the all dataset by chuncks should use index=0, then index=limit, then index=2*limit, and so on.

    The table on page 42 you are likely referring to states the below:

    ?offset=10&limit=20

    Get the twenty resources starting at the tenth


    I am not sure what is considering ambiguous here.

    Kind regards,

    ------------------------------
    Christophe MICHEL
    Amdocs Management Limited
    ------------------------------



  • 3.  RE: Correct implementation offset and limit for paging

    TM Forum Member
    Posted Mar 05, 2021 04:26

    Thanks Christophe.

    You found the exact spot. ​"Get the twenty resources starting at the tenth" caused my confusion as I would expect the "eleventh resource".

    For myself, the offset=2 variant also makes more sense.



    ------------------------------
    Jan Lemmermann
    OSS Lead Architect
    EWE TEL GmbH
    ------------------------------