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 "page" param to ranking on apiv2 #19

Closed
wants to merge 1 commit into from
Closed

Conversation

JuanM4T
Copy link

@JuanM4T JuanM4T commented Jun 9, 2021

For being able to get more than only the first 49 people on the rankings.

@JuanM4T JuanM4T changed the title Add page to ranking on apiv2 Add "page" param to ranking on apiv2 Jun 9, 2021
@tybug
Copy link
Owner

tybug commented Jun 9, 2021

The proper way to do this is actually to use the cursor parameter, which is how the osu api handles pagination:

# using returned cursor which automatically increments to the next page
r = api.ranking("osu", RankingType.PERFORMANCE)
cursor = r.cursor
print(f"cursor page: {cursor.page}") # 2
print(r.ranking[0].global_rank)
r = api.ranking("osu", RankingType.PERFORMANCE, cursor=r.cursor)
print(r.ranking[0].global_rank)

# manually constructing a cursor
c = Cursor(page=3)
r = api.ranking("osu", RankingType.PERFORMANCE, cursor=c)
print(r.ranking[0].global_rank)

We need better documentation on this, but that's the intended usage.

@tybug tybug closed this Jun 9, 2021
@tybug
Copy link
Owner

tybug commented Jun 9, 2021

I've fleshed out our readme more and added a section for pagination: https://github.com/circleguard/ossapi#pagination

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

Successfully merging this pull request may close these issues.

None yet

2 participants