Evolution Client
Covers the PokéAPI's evolution section: evolution chains, the triggers that advance them, and the hidden values some evolutions are decided by.
import { EvolutionClient } from 'pokenode-ts';
const api = new EvolutionClient();
const chain = await api.getEvolutionChainById(1);
console.log(chain.chain.species.name); // "bulbasaur"
console.log(chain.chain.evolves_to[0].species.name); // "ivysaur"Methods
Evolution chains
| Method | Returns |
|---|---|
getEvolutionChainById(id) | EvolutionChain |
listEvolutionChains(offset?, limit?) | APIResourceList |
Evolution triggers
| Method | Returns |
|---|---|
getEvolutionTriggerByName(name) | EvolutionTrigger |
getEvolutionTriggerById(id) | EvolutionTrigger |
listEvolutionTriggers(offset?, limit?) | NamedAPIResourceList |
Evolution variables
| Method | Returns |
|---|---|
getEvolutionVariableByName(name) | EvolutionVariable |
getEvolutionVariableById(id) | EvolutionVariable |
listEvolutionVariables(offset?, limit?) | NamedAPIResourceList |
An EvolutionVariable — the encryption constant, the personality value, the direction and length of Milcery's spin — is what an EvolutionDetail.condition_expression reads. Its source says whether the value is stored on the Pokémon (pokemon) or supplied by the player (player-input). See hidden values.
INFO
Evolution chains have no names upstream, so there is no getEvolutionChainByName. To go from a Pokémon to its chain, read evolution_chain.url off its species and follow it — see below.
Walking a chain
EvolutionChain.chain is a recursive ChainLink: each link carries the species at that stage and an evolves_to array of the links after it. Branching evolutions — Eevee — are why it is an array rather than a single value.
import { EvolutionClient, type ChainLink } from 'pokenode-ts';
const names = (link: ChainLink): string[] => [
link.species.name,
...link.evolves_to.flatMap(names),
];
const chain = await new EvolutionClient().getEvolutionChainById(67);
console.log(names(chain.chain)); // eevee and every evolution it branches intoFrom a Pokémon to its chain
The chain id is not the Pokémon id. Go through the species:
import { PokemonClient, EvolutionClient, UtilityClient, type EvolutionChain } from 'pokenode-ts';
const species = await new PokemonClient().getPokemonSpeciesByName('eevee');
// The species carries a URL rather than an id, so follow it directly.
const chain = await new UtilityClient().getResourceByUrl<EvolutionChain>(
species.evolution_chain.url,
);Using constants
import { EvolutionClient, EVOLUTION_TRIGGERS, EVOLUTION_VARIABLES } from 'pokenode-ts';
const api = new EvolutionClient();
const levelUp = await api.getEvolutionTriggerById(EVOLUTION_TRIGGERS.LEVEL_UP);
const ec = await api.getEvolutionVariableById(EVOLUTION_VARIABLES.ENCRYPTION_CONSTANT);