API Documentation
PokéRandom uses the open-source PokéAPI to fetch Pokémon data. This page documents the API endpoints we use and provides examples for developers who want to build their own Pokémon applications.
PokéAPI Overview
PokéAPI is a free, open-source REST API that provides data about all 1,025 Pokémon from the main series games. It requires no authentication and has no rate limits (though we recommend caching responses to be respectful).
Base URL: https://pokeapi.co/api/v2
📢 Advertisement
Ad space — configure AdSense to enable
Endpoints We Use
GET /pokemon/:id
Fetch a single Pokémon by its National Pokédex ID (1-1025). Returns base stats, types, abilities, sprites, and cries.
fetch("https://pokeapi.co/api/v2/pokemon/25") .then(r => r.json()) .then(pokemon => console.log(pokemon.name)); // "pikachu"GET /pokemon-species/:id
Fetch species data including flavor text, evolution chain URL, generation, gender rate, and legendary/mythical status.
fetch("https://pokeapi.co/api/v2/pokemon-species/25") .then(r => r.json()) .then(species => console.log(species.is_legendary)); // falseGET /evolution-chain/:id
Fetch the full evolution chain for a Pokémon. Returns a nested tree of species and their evolution details (level, item, trigger).
fetch("https://pokeapi.co/api/v2/evolution-chain/10") .then(r => r.json()) .then(chain => console.log(chain.chain.species.name)); // "bulbasaur"GET /type/:name
Fetch all Pokémon of a specific type. Returns a list of Pokémon that have the specified type as either their primary or secondary type.
fetch("https://pokeapi.co/api/v2/type/fire") .then(r => r.json()) .then(type => console.log(type.pokemon.length)); // ~85 fire typesCaching Strategy
PokéRandom caches all API responses for 24 hours using Next.js’s built-infetch() caching:
fetch(url, { next: { revalidate: 86400 } }); // 24 hoursThis reduces load on PokéAPI’s servers and makes our pages load faster. We also maintain an in-memory cache for the most common requests during a single build cycle.
Sprite Artwork URLs
Pokémon sprites and official artwork are served from the PokeAPI/sprites GitHub repository. These URLs follow predictable patterns and don’t require an API call:
// Official artwork (high quality)
https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/{id}.png
// Official artwork (shiny)
https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/shiny/{id}.png
// Pixel sprite (small, fast loading)
https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/{id}.png
// Pokémon cry (audio)
https://raw.githubusercontent.com/PokeAPI/cries/main/cries/pokemon/latest/{id}.oggBuilding Your Own Pokémon App
If you want to build your own Pokémon application using PokéAPI, we recommend using TypeScript with a typed fetcher. PokéRandom’s pokemon-api.ts module (available in our GitHub repository) provides a complete, typed wrapper around the API with caching, error handling, and helper functions for filtering by generation, type, and legendary status.
Always cache API responses, as PokéAPI is a community-maintained project and excessive requests can slow it down for everyone. Consider using a CDN like Cloudflare to cache responses at the edge. And if you build something cool with PokéAPI, consider donating to the project on their website.