pokedex icon indicating copy to clipboard operation
pokedex copied to clipboard

Pokemon IDs Different in 2 urls.

Open TunerBotDev opened this issue 3 years ago • 4 comments

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

TunerBotDev avatar Jun 13 '22 15:06 TunerBotDev

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

Naramsim avatar Jun 13 '22 18:06 Naramsim

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.

TunerBotDev avatar Jun 17 '22 12:06 TunerBotDev

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

merfed avatar Jun 21 '22 17:06 merfed

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

Naramsim avatar Jun 21 '22 20:06 Naramsim