PokeAPI / pokedex

PokeAPI's fork for adding gen-8 data.
https://github.com/PokeAPI/pokedex/tree/master-pokeapi/pokeapi
MIT License
43 stars 38 forks source link

Pokemon IDs Different in 2 urls. #103

Open TunerBotDev opened 2 years ago

TunerBotDev commented 2 years ago

let suppose a url https://pokeapi.co/api/v2/pokemon/charmander. here the ID of the pokemon is given as 4. okay so now since the url https://pokeapi.co/api/v2/evolution-chain/4 only supports number, when we fetch it, WHY IS IT SHOWING CATERPIE

Naramsim commented 2 years ago

yes, IDs are related to resources. So you are actually requesting two different things.

TunerBotDev commented 2 years ago

yes, IDs are related to resources. So you are actually requesting two different things.

but there is now way to interaconnect both of the URLs. like im making a pokedex and need to fetch evolution chain as well, so i cannot fetch the evolution chain since the ID of the pokemon provided in the /pokemon url is different in evolution-chain url. please add feature to fetch evolution chains via names too.

merfed commented 2 years ago

yes, IDs are related to resources. So you are actually requesting two different things.

but there is now way to interaconnect both of the URLs. like im making a pokedex and need to fetch evolution chain as well, so i cannot fetch the evolution chain since the ID of the pokemon provided in the /pokemon url is different in evolution-chain url. please add feature to fetch evolution chains via names too.

Use the pokemon-species endpoint:

https://pokeapi.co/api/v2/pokemon-species/charmander

Naramsim commented 2 years ago

Through the endpoint specified by @merfed you can get the evolution chain:

So you would need to make 3 API calls and 3 JSON parsing:

  1. /pokemon
  2. /pokemon-species
  3. /evolution-chain

That's how this API works