Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination for GET requests #69

Open
aaroncohen73 opened this issue Jul 13, 2016 · 6 comments
Open

Pagination for GET requests #69

aaroncohen73 opened this issue Jul 13, 2016 · 6 comments

Comments

@aaroncohen73
Copy link
Contributor

Also see this issue

It would be a very useful feature to be able to paginate GET requests (especially requests to the /times endpoint). In the previously mentioned issue, @LyonesGamer suggested that ?limit and ?skip parameters be added (to correspond to LIMIT and OFFSET queries on an SQL database). The behavior for these parameters might look something like this:

?limit=:numobjects

  • Limits the number of objects returned to :numobjects
  • If ?skip isn't specified, it defaults to 0

?skip=:toskip

  • Returns objects after skipping :toskip objects
  • If ?limit isn't specified, it defaults to all objects after :toskip objects

For ordering the objects for either of these parameters, it could be specified that the objects should be returned in order of creation date with the most recently created object first.

@MorganEPatch
Copy link
Contributor

The ?limit=&skip= suggestion is one possibility, by the way. We could also just have a ?page= parameter and have that limit to a fixed number of values.

it could be specified that the objects should be returned in order of creation date with the most recently created object first.

This would be my recommendation as well.

@aaroncohen73
Copy link
Contributor Author

While ?page would be slightly simpler from the API user's point of view (and I don't see a ton of use for the fine-grained control afforded by ?limit and ?skip), I'm in favor of the other option because it's more flexible.

@mathuin
Copy link
Contributor

mathuin commented Jul 14, 2016

Personally, I am -1 to ?page= -- let us not dictate to our user community how long their pages must be.

An absolutely unscientific survey: reddit does this by ?count=X&after=tag, hacker news does this by ?p=X, facebook hides it from the user.

@MorganEPatch
Copy link
Contributor

MorganEPatch commented Jul 14, 2016

@mathuin Are you sure that's how reddit does it? Maybe internally or something. I've only ever seen my address bar show reddit.com?page=X...

Edit: Nope, I see now. New discovery. Reddit, which has true pagination, uses ?count=X&after=tag, while the Reddit Enhancement Suite browser extension, which provides infinite scrolling instead, replaces it with reddit.com/#page=X in the address bar and browser history and internally converts it to Reddit's representation. So there's that.

@mathuin
Copy link
Contributor

mathuin commented Jul 14, 2016

My 'next' button at the bottom of my Reddit home page currently has this link: https://www.reddit.com/?count=25&after=t3_4ssszc.

@MorganEPatch
Copy link
Contributor

@mathuin So even Reddit and its users can't agree on it, it seems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants