API Pagination Standards -


i have been working on api , pagination required. 25 elements returned in each request. looking around standards , seem see 2 different things going on.

  1. the link header

example:

link: <https://api.github.com/user/repos?page=3&per_page=100>; rel="next",   <https://api.github.com/user/repos?page=50&per_page=100>; rel="last" 

  1. in json response

example:

"paging":  {     "previous":  "http://api.example.com/foo?since=timestamp"     "next":  "http://api.example.com/foo?since=timestamp2" } 

question:

should both? , being said; key "paging" correct key? or "links" or "pagination"

i depends on structure of data return (and may return in future).

if never have nested objects need own links, using link header (mildly) preferable, because it's more correct. issue nested objects can't nest link headers.

consider following collection entity:

{     "links": {         "collection": "/cards?offset=0&limit=25"     },     "data": [         {             "cardname": "island of wak-wak",             "type": "land",             "links": {                 "set": "/cards?set=arabian knights"             }         },         {             "cardname": "mana drain",             "type": "interrupt",             "links": {                 "set": "/cards?set=legends"             }         }     ] } 

there's no way include links cards in headers.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -