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

Create get_pokemons() method. #37

Open
lflimeira opened this issue Mar 5, 2019 · 3 comments
Open

Create get_pokemons() method. #37

lflimeira opened this issue Mar 5, 2019 · 3 comments

Comments

@lflimeira
Copy link

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:

{
  "count": 964,
  "next": "https://pokeapi.co/api/v2/pokemon/?offset=20&limit=20",
  "previous": null,
  "results": [
    {
      "name": "bulbasaur",
      "url": "https://pokeapi.co/api/v2/pokemon/1/"
    },
    {
      "name": "ivysaur",
      "url": "https://pokeapi.co/api/v2/pokemon/2/"
    },
    {
      "name": "venusaur",
      "url": "https://pokeapi.co/api/v2/pokemon/3/"
    },
    {
      "name": "charmander",
      "url": "https://pokeapi.co/api/v2/pokemon/4/"
    },
    {
      "name": "charmeleon",
      "url": "https://pokeapi.co/api/v2/pokemon/5/"
    },
    {
      "name": "charizard",
      "url": "https://pokeapi.co/api/v2/pokemon/6/"
    },
    {
      "name": "squirtle",
      "url": "https://pokeapi.co/api/v2/pokemon/7/"
    },
    {
      "name": "wartortle",
      "url": "https://pokeapi.co/api/v2/pokemon/8/"
    },
    {
      "name": "blastoise",
      "url": "https://pokeapi.co/api/v2/pokemon/9/"
    },
    {
      "name": "caterpie",
      "url": "https://pokeapi.co/api/v2/pokemon/10/"
    },
    {
      "name": "metapod",
      "url": "https://pokeapi.co/api/v2/pokemon/11/"
    },
    {
      "name": "butterfree",
      "url": "https://pokeapi.co/api/v2/pokemon/12/"
    },
    {
      "name": "weedle",
      "url": "https://pokeapi.co/api/v2/pokemon/13/"
    },
    {
      "name": "kakuna",
      "url": "https://pokeapi.co/api/v2/pokemon/14/"
    },
    {
      "name": "beedrill",
      "url": "https://pokeapi.co/api/v2/pokemon/15/"
    },
    {
      "name": "pidgey",
      "url": "https://pokeapi.co/api/v2/pokemon/16/"
    },
    {
      "name": "pidgeotto",
      "url": "https://pokeapi.co/api/v2/pokemon/17/"
    },
    {
      "name": "pidgeot",
      "url": "https://pokeapi.co/api/v2/pokemon/18/"
    },
    {
      "name": "rattata",
      "url": "https://pokeapi.co/api/v2/pokemon/19/"
    },
    {
      "name": "raticate",
      "url": "https://pokeapi.co/api/v2/pokemon/20/"
    }
  ]
}
@Kronopt Kronopt self-assigned this Mar 5, 2019
@Kronopt
Copy link
Member

Kronopt commented Mar 5, 2019

I've been thinking about adding support for pagination.
I might eventually.
When I do, it will cover every available resource, not just pokemon.

@lflimeira
Copy link
Author

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?

@Kronopt
Copy link
Member

Kronopt commented Mar 8, 2019

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.

@Kronopt Kronopt mentioned this issue Jun 27, 2019
@Kronopt Kronopt removed their assignment Dec 20, 2020
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

2 participants