Using Range header for partial lookup/paging

53 views
Skip to first unread message

David Waite

unread,
Aug 12, 2016, 3:55:02 PM8/12/16
to API Craft
According to RFC 7233, the Range header units are extensible, although the only official values are "bytes" and "none".

I was wondering if anyone has made a range unit of say "objects", where a resource representing a sequence of data objects will return a subset of those objects when the range header is given.

For example, a /events endpoint which would return all 1,000 entries in a JSON array on a normal GET would return just the ten most recent given a header of

Range: objects=-10

which would return a JSON array of just those entries, e.g.

206 Partial Content HTTP/1.1
Content-Range: objects 990-999/1000

Has anyone seen API which do such a thing?

-David Waite

Anderson Muller

unread,
Aug 16, 2016, 5:42:47 AM8/16/16
to API Craft
We implemented this pattern for paging. It was not difficult and clients accepted it well.

Anderson Muller

unread,
Aug 16, 2016, 5:49:37 AM8/16/16
to API Craft
Reply all
Reply to author
Forward
0 new messages