Pokeapi: Pokemon count or random.

Created on 14 Mar 2016  路  5Comments  路  Source: PokeAPI/pokeapi

Is there a way to get the current count of Pokemon? I know you can do /pokemon/?limit=1000 to get a complete list of IDs and a count, however this count isn't accurate for a pokedex. It currently says 811 when I was expecting 721 due to the extras starting at 10001. My goal is to return a random Pokemon. The best option would be adding a random option to the API call where it returns a random entry on your end. The other option would be for me to get a count and just randomly generate a number.

enhancement

Most helpful comment

I do a call to /pokemon-species/?limit=0 and grab the count property.

All 5 comments

Digging around a little more I was able to find the end point for /pokedex/national/. This gives pokemon_entries which has the 721 I'm looking for. One suggestion would be to add pokemon_count in the returned data that was a count of pokemon_entries in a specific Pokedex. I mean it's just as easy for me to count the entries but it's a helpful piece of data to have in the API anyways.

That gives me a work around for what I'm looking for but having a random option to the API would be extremely handy; maybe something like /pokemon/random/ or /pokemon/?random. My flow right now would be query /pokedex/national/ to count pokemon_entries. Select a random number using count as the max and query /pokemon/x/.

@fleeting you could also call against Pokemon-species limit 1000. Pokemon species is the base resource for Pokemon. I could really make this more clear in the docks.

@fleeting I have seen some interest in random from others. The only reason I consider against it is that we highly encourage caching of data on your end (which could also hold the count). I'll leave this up as a feature request and see what people think.

I do a call to /pokemon-species/?limit=0 and grab the count property.

@sargunster That is perfect for the count, thanks!

@zaneadix Species being the base resource makes sense now. I get wanting people to cache and random going against it. Now that I have an easy way to get the correct count and can cache it, doing random on my end isn't a problem. Thanks!

Was this page helpful?
0 / 5 - 0 ratings