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

Add new paging strategy for since_id/max_id/amount #1

Open
brianmuse opened this issue Jun 27, 2013 · 0 comments
Open

Add new paging strategy for since_id/max_id/amount #1

brianmuse opened this issue Jun 27, 2013 · 0 comments

Comments

@brianmuse
Copy link
Member

Currently this library supports a paging pattern where the user provides page/per_page params which is interpolated into a limit and offset.

Another paging strategy used by APIs (see instagram/twitter) allows the user to specify an ID and an amount.

Example:

Providing since_id = 10 and amount = 5 would return 5 rows in descending order as follows:

id: 15
id: 14
id: 13
id: 12
id: 11

Providing max_id = 10 and amount = 5 would return 5 rows in descending order as follows:

id: 10
id: 9
id: 8
id: 7
id: 6

Note that since_id is exclusive and max_id is inclusive.

Pagination attribute:

The pagination attribute in the response is also handled a little different. Below is an example of Instagram's implementation:

    "pagination": {
        "next_url": "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296",
        "next_max_id": "13872296"
    }

Incompatibility

The page/per_page and since_id/max_id/amount paging strategies are mutually exclusive and incompatible with each other. For this reason, if params from both strategies are found in the same requests, an exception should be throws.

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

1 participant