Open lflimeira opened 5 years ago
I've been thinking about adding support for pagination. I might eventually. When I do, it will cover every available resource, not just pokemon.
Good, so I'm going to create pagination issues for the others resources as well, this way, everybody who wants to help can based on those issues too. What do you think about it?
I think a general pagination issue would be better. But yeah, feel free to open it, yes! You can also try to implement this feature yourself, if you think you can do it!
As per the pokeapi docs:
Calling any API endpoint without a resource ID or name will return a paginated list of available resources for that API. By default, a list "page" will contain up to 20 resources. If you would like to change this just add a 'limit' query parameter, e.g. ?limit=60. You can use 'offset' to move to the next page, e.g. ?limit=60&offset=60.
So, it should be easy to implement the calling of any V2Client.get_
method without any parameters.
Then implement the limit
and offset
parameters.
The PokeAPI allows getting a list of Pokemons with pagination, we could include this functionality in to the wrapper and allows to get a list of Pokemon objects and pass not required pagination arguments.
Example:
def get_pokemons(offset=0, limit=20):
It will return: