Skip to content

Evolution Chains

PokéAPI’s evolution-chain endpoint returns a species’ full evolutionary tree, including triggers, item/level requirements, form rules, regional variants, and formula-based splits.

This guide covers the data model, common branching patterns, a parsing algorithm, and how to evaluate RPN condition expressions.


Each chain is a recursive tree of ChainLink objects with a species and an evolves_to list. Inside each child link, evolution_details lists the conditions required to evolve:

Field Type Description
required_pokemon_form object? Specific form required to trigger this evolution ({name, url}). Defaults to the base species if not set.
evolved_pokemon_form object? Specific form resulting from this evolution ({name, url}). Defaults to the base species if not set.
condition_expression object? Postfix / Reverse Polish Notation (RPN) formula for data-driven form branching ({expression, percentage_chance}).

Standard condition keys: trigger, min_level, item, held_item, time_of_day, location, gender, known_move, region, etc.

Source Noderequired_pokemon_form OR parent species
Target Nodeevolved_pokemon_form OR child species

Most evolution chains are linear, but several Pokémon use form-specific, regional, or formula-driven branches:

The pre-evolution form determines the evolved form:

├── ChainLink (Species: Burmy)
│ ├── evolves_to: Wormadam
│ │ ├── detail: { required_pokemon_form: "burmy-plant", evolved_pokemon_form: "wormadam-plant", gender: female, min_level: 20 }
│ │ ├── detail: { required_pokemon_form: "burmy-sandy", evolved_pokemon_form: "wormadam-sandy", gender: female, min_level: 20 }
│ │ └── detail: { required_pokemon_form: "burmy-trash", evolved_pokemon_form: "wormadam-trash", gender: female, min_level: 20 }
│ └── evolves_to: Mothim
│ └── detail: { gender: male, min_level: 20 }
burmy (burmy-plant)burmyburmy-plant
burmy (burmy-sandy)burmyburmy-sandy
burmy (burmy-trash)burmyburmy-trash
wormadam (wormadam-plant)wormadamwormadam-plant
wormadam (wormadam-sandy)wormadamwormadam-sandy
wormadam (wormadam-trash)wormadamwormadam-trash
mothimmothim

A species evolves into different regional forms depending on the region:

├── ChainLink (Species: Pikachu)
│ └── evolves_to: Raichu
│ ├── detail: { item: "thunder-stone" }
│ └── detail: { item: "thunder-stone", region: "alola" }
pikachupikachu
raichu (Kantonian)raichuKantonian
raichu (raichu-alola)raichuraichu-alola

Branching driven by Encryption Constant (EC) or Personality ID (PID) using Reverse Polish Notation (RPN):

├── ChainLink (Species: Tandemaus)
│ └── evolves_to: Maushold
│ ├── detail: { min_level: 25, condition_expression: { expression: "EC 100 % 0 !=" } }
│ └── detail: { min_level: 25, condition_expression: { expression: "EC 100 % 0 ==" } }
tandemaustandemaus
maushold (family-of-four)mausholdfamily-of-four
maushold (family-of-three)mausholdfamily-of-three

Only a specific pre-evolution form can evolve into the target form:

├── ChainLink (Species: Rockruff)
│ └── evolves_to: Lycanroc
│ ├── detail: { min_level: 25, time_of_day: "day" }
│ ├── detail: { min_level: 25, time_of_day: "night", evolved_pokemon_form: "lycanroc-midnight" }
│ └── detail: { required_pokemon_form: "rockruff-own-tempo", evolved_pokemon_form: "lycanroc-dusk", min_level: 25, time_of_day: "dusk" }
rockruff (base form)rockruffbase form
rockruff (rockruff-own-tempo)rockruffrockruff-own-tempo
lycanroc (lycanroc-midday)lycanroclycanroc-midday
lycanroc (lycanroc-midnight)lycanroclycanroc-midnight
lycanroc (lycanroc-dusk)lycanroclycanroc-dusk

Convert an evolution-chain payload into directed edges:

FUNCTION ParseEvolutionChain(chain_link):
parent_species = chain_link.species.name
FOR EACH child IN chain_link.evolves_to:
child_species = child.species.name
// Case 1: Child link has explicit evolution details
IF child.evolution_details IS NOT EMPTY:
FOR EACH detail IN child.evolution_details:
// 1. Determine Source Node (Form-specific OR Species fallback)
IF detail.required_pokemon_form IS SET:
source_node = detail.required_pokemon_form.name
ELSE:
source_node = parent_species
// 2. Determine Target Node (Form-specific OR Species fallback)
IF detail.evolved_pokemon_form IS SET:
target_node = detail.evolved_pokemon_form.name
ELSE:
target_node = child_species
// 3. Register Directed Edge
ADD_EDGE(
source = source_node,
target = target_node,
conditions = detail
)
// Case 2: Base link with no specific conditions
ELSE:
ADD_EDGE(
source = parent_species,
target = child_species,
conditions = DEFAULT_CONDITIONS
)
// Recurse down the chain
ParseEvolutionChain(child)

How it works:

  1. Read the current species (parent_species) and loop through each child in evolves_to.
  2. Resolve the source and target nodes: use required_pokemon_form / evolved_pokemon_form when present, otherwise fall back to the base species name.
  3. Emit a directed edge for each entry in evolution_details (or a default edge if evolution_details is empty).
  4. Recurse into each child link to walk the entire chain.

When condition_expression is set, expression is a space-separated Reverse Polish Notation string:

Example: "EC 100 % 0 =="
Stack Execution:
1. Read "EC" -> Push [ EC ]
2. Read "100" -> Push [ EC, 100 ]
3. Read "%" -> Pop 100, EC -> Push [ (EC % 100) ]
4. Read "0" -> Push [ (EC % 100), 0 ]
5. Read "==" -> Pop 0, (EC % 100) -> Push [ (EC % 100) == 0 ]
Result:
True --> Branch to condition target
False --> Check next branch

A self-contained script that parses evolution chains into directed edges and evaluates RPN expressions:

parse_evolution.py
import json
import urllib.request
from typing import Any
def rpn_to_infix(expr: str) -> str:
"""Convert a space-separated RPN expression (e.g. 'EC 100 % 0 ==') to human-readable infix."""
operators = {"+", "-", "*", "/", "%", ">>", "<<", "==", "!=", "<", "<=", ">", ">="}
stack: list[str] = []
for token in expr.split():
if token in operators:
b, a = stack.pop(), stack.pop()
stack.append(f"({a} {token} {b})")
else:
stack.append(token)
return stack[0] if stack else expr
def parse_evolution_chain(data: dict[str, Any]) -> list[dict[str, Any]]:
"""Traverse an evolution chain payload into a flat list of directed edges."""
edges: list[dict[str, Any]] = []
def traverse(link: dict[str, Any]):
parent_species = link["species"]["name"]
for child in link.get("evolves_to", []):
child_species = child["species"]["name"]
details = child.get("evolution_details", [])
if not details:
edges.append({
"from": parent_species,
"to": child_species,
"conditions": {"trigger": "default"},
})
traverse(child)
continue
for d in details:
# 1. Resolve source node (Form -> Species fallback)
req_form = d.get("required_pokemon_form")
source = req_form["name"] if req_form else parent_species
# 2. Resolve target node (Form -> Species fallback)
evo_form = d.get("evolved_pokemon_form")
target = evo_form["name"] if evo_form else child_species
# 3. Clean and format conditions
conds: dict[str, Any] = {}
for k, v in d.items():
if k in ("required_pokemon_form", "evolved_pokemon_form", "is_default", "version_group"):
continue
if k == "condition_expression" and v:
conds["formula"] = rpn_to_infix(v.get("expression", ""))
if v.get("percentage_chance") is not None:
conds["chance"] = f"{v['percentage_chance']}%"
elif isinstance(v, dict) and "name" in v:
conds[k] = v["name"]
elif v is not None and v is not False and v != "":
conds[k] = v
edges.append({
"from": source,
"to": target,
"conditions": conds,
"version_group": d.get("version_group", {}).get("name"),
})
traverse(child)
traverse(data["chain"])
return edges
def inspect_evolution_chain(chain_id: int):
"""Fetch and print the parsed evolution tree for a given chain ID."""
url = f"https://pokeapi.co/api/v2/evolution-chain/{chain_id}/"
req = urllib.request.Request(url, headers={"User-Agent": "PokeAPI-Client"})
with urllib.request.urlopen(req) as resp:
payload = json.loads(resp.read().decode("utf-8"))
edges = parse_evolution_chain(payload)
print(f"\n{'='*20} Evolution Chain #{chain_id} {'='*20}")
for edge in edges:
cond_str = ", ".join(f"{k}: {v}" for k, v in edge["conditions"].items())
vg_str = f" ({edge['version_group']})" if edge.get("version_group") else ""
print(f" {edge['from']} ──> {edge['to']} [{cond_str}]{vg_str}")
if __name__ == "__main__":
# 1. Form-Preserving Evolution (Burmy -> Wormadam/Mothim)
inspect_evolution_chain(213)
# 2. Formulaic RPN Split (Tandemaus -> Maushold)
inspect_evolution_chain(485)
# 3. Form-Exclusive Split (Rockruff -> Lycanroc)
inspect_evolution_chain(383)
# 4. Regional Evolution Split (Pikachu -> Raichu / Raichu-Alola)
inspect_evolution_chain(10)
==================== Evolution Chain #213 ====================
burmy-plant ──> wormadam-plant [trigger: level-up, gender: 1, min_level: 20] (diamond-pearl)
burmy-sandy ──> wormadam-sandy [trigger: level-up, gender: 1, min_level: 20] (diamond-pearl)
burmy-trash ──> wormadam-trash [trigger: level-up, gender: 1, min_level: 20] (diamond-pearl)
burmy ──> mothim [trigger: level-up, gender: 2, min_level: 20] (diamond-pearl)
==================== Evolution Chain #485 ====================
tandemaus ──> maushold-family-of-four [trigger: in-battle-level-up, min_level: 25, formula: ((EC % 100) != 0), chance: 99%] (scarlet-violet)
tandemaus ──> maushold-family-of-three [trigger: in-battle-level-up, min_level: 25, formula: ((EC % 100) == 0), chance: 1%] (scarlet-violet)
==================== Evolution Chain #383 ====================
rockruff ──> lycanroc-midday [trigger: level-up, min_level: 25, time_of_day: day] (sun-moon)
rockruff ──> lycanroc-midnight [trigger: level-up, min_level: 25, time_of_day: night] (sun-moon)
rockruff-own-tempo ──> lycanroc-dusk [trigger: level-up, min_level: 25, time_of_day: dusk] (sun-moon)
==================== Evolution Chain #10 ====================
pichu ──> pikachu [trigger: level-up, min_happiness: 220] (gold-silver)
pikachu ──> raichu [item: thunder-stone, trigger: use-item] (red-blue)
pikachu ──> raichu-alola [item: thunder-stone, trigger: use-item, region: alola] (sun-moon)

PokéAPI sends evolution chains as a tree, while your application’s parsed model is a DAG:

In JSON, the response is an N-ary Tree (Rose Tree) where each ChainLink has N ≥ 0 children in evolves_to (N = 1 for Charmander, N = 8 for Eevee, N = 0 for single-stage Pokémon), traversed with Depth-First Search (DFS) or Breadth-First Search (BFS).

For example, Eevee’s wire format is a 1-to-8 N-ary tree:

eevee (Root)eeveeRoot
vaporeonvaporeon
jolteonjolteon
flareonflareon
espeonespeon
umbreonumbreon
leafeonleafeon
glaceonglaceon
sylveonsylveon

6.2 Domain Model: Directed Acyclic Graph (DAG)

Section titled “6.2 Domain Model: Directed Acyclic Graph (DAG)”

Once you account for form-specific branches and alternative methods, the true model is an Edge-Labeled Directed Acyclic Multi-Graph (DAG):

  • Vertices (V): Forms (e.g. burmy-plant, wormadam-sandy) or base Species.
  • Directed Edges (E): u ──(conditions)──> v transitions.
  • Multi-Edges (Parallel Edges): Two nodes can have multiple distinct paths between them representing alternative methods (e.g. Eevee ──(Moss Rock)──> Leafeon vs. Eevee ──(Leaf Stone)──> Leafeon).
  • Forest (Disjoint Subgraphs): Species with distinct pre-evolution varieties that never cross-breed/switch forms (like Sinistea Phony vs. Antique, or Burmy Plant/Sandy/Trash) project into a Forest of parallel trees sharing target nodes (like Mothim).
  • Topological Sort: Evolutions are strictly forward-progressing with no cycles (DAG), allowing stages (Baby → Basic → Stage 1 → Stage 2) to be topologically sorted.

PokéAPI Concept DSA Equivalent Description
chain Root Node The origin species of the evolutionary family.
evolves_to Adjacency List / Child Pointers Outgoing directed branches to next evolutionary stages.
evolution_details Edge Weights / Predicates Guard conditions (level, item, RPN expression) required to traverse the edge.
Multiple details on 1 link Multi-Graph (Parallel Edges) Multiple valid methods to evolve between the same source and target.
required_pokemon_form Vertex Splitting / Forest Projection Decomposes a single species tree into distinct form lineages.