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.
1. How Chains Work
Section titled “1. How Chains Work”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.
2. Branching Patterns
Section titled “2. Branching Patterns”Most evolution chains are linear, but several Pokémon use form-specific, regional, or formula-driven branches:
2.1 Form-Preserving (Burmy)
Section titled “2.1 Form-Preserving (Burmy)”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 }{ "species": { "name": "burmy" }, "evolves_to": [ { "species": { "name": "wormadam" }, "evolution_details": [ { "required_pokemon_form": { "name": "burmy-plant" }, "evolved_pokemon_form": { "name": "wormadam-plant" }, "gender": 1, "min_level": 20 }, { "required_pokemon_form": { "name": "burmy-sandy" }, "evolved_pokemon_form": { "name": "wormadam-sandy" }, "gender": 1, "min_level": 20 }, { "required_pokemon_form": { "name": "burmy-trash" }, "evolved_pokemon_form": { "name": "wormadam-trash" }, "gender": 1, "min_level": 20 } ] }, { "species": { "name": "mothim" }, "evolution_details": [{ "gender": 2, "min_level": 20 }] } ]}2.2 Regional Variants (Pikachu)
Section titled “2.2 Regional Variants (Pikachu)”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" }{ "species": { "name": "pikachu" }, "evolves_to": [ { "species": { "name": "raichu" }, "evolution_details": [ { "item": { "name": "thunder-stone" } }, { "item": { "name": "thunder-stone" }, "region": { "name": "alola" } } ] } ]}2.3 Formula Splits (Tandemaus)
Section titled “2.3 Formula Splits (Tandemaus)”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 ==" } }{ "species": { "name": "tandemaus" }, "evolves_to": [ { "species": { "name": "maushold" }, "evolution_details": [ { "min_level": 25, "condition_expression": { "expression": "EC 100 % 0 !=", "percentage_chance": 99 } }, { "min_level": 25, "condition_expression": { "expression": "EC 100 % 0 ==", "percentage_chance": 1 } } ] } ]}2.4 Form-Exclusive (Rockruff)
Section titled “2.4 Form-Exclusive (Rockruff)”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" }{ "species": { "name": "rockruff" }, "evolves_to": [ { "species": { "name": "lycanroc" }, "evolution_details": [ { "min_level": 25, "time_of_day": "day" }, { "min_level": 25, "time_of_day": "night", "evolved_pokemon_form": { "name": "lycanroc-midnight" } }, { "required_pokemon_form": { "name": "rockruff-own-tempo" }, "evolved_pokemon_form": { "name": "lycanroc-dusk" }, "min_level": 25, "time_of_day": "dusk" } ] } ]}3. Parsing Algorithm
Section titled “3. Parsing Algorithm”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:
- Read the current species (
parent_species) and loop through each child inevolves_to. - Resolve the source and target nodes: use
required_pokemon_form/evolved_pokemon_formwhen present, otherwise fall back to the base species name. - Emit a directed edge for each entry in
evolution_details(or a default edge ifevolution_detailsis empty). - Recurse into each
childlink to walk the entire chain.
4. Evaluating RPN Conditions
Section titled “4. Evaluating RPN Conditions”When condition_expression is set, expression is a space-separated Reverse Polish Notation string:
- Variables:
EC(Encryption Constant),PID(Personality ID) - Operators:
+,-,*,/,%,>>,<<,==,!=,<,<=,>,>=
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 branch5. Python Example
Section titled “5. Python Example”A self-contained script that parses evolution chains into directed edges and evaluates RPN expressions:
import jsonimport urllib.requestfrom 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)6. Data Structures: Tree vs. DAG
Section titled “6. Data Structures: Tree vs. DAG”PokéAPI sends evolution chains as a tree, while your application’s parsed model is a DAG:
6.1 Wire Format: N-ary Tree
Section titled “6.1 Wire Format: N-ary Tree”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:
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)──> vtransitions. - Multi-Edges (Parallel Edges): Two nodes can have multiple distinct paths between them representing alternative methods (e.g.
Eevee ──(Moss Rock)──> Leafeonvs.Eevee ──(Leaf Stone)──> Leafeon). - Forest (Disjoint Subgraphs): Species with distinct pre-evolution varieties that never cross-breed/switch forms (like
Sinistea Phonyvs.Antique, orBurmy Plant/Sandy/Trash) project into a Forest of parallel trees sharing target nodes (likeMothim). - Topological Sort: Evolutions are strictly forward-progressing with no cycles (DAG), allowing stages (Baby → Basic → Stage 1 → Stage 2) to be topologically sorted.
6.3 Summary Mapping Table
Section titled “6.3 Summary Mapping Table”| 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. |
