pokefetch
v1.0.0
Published
Simple Pokémon data client for JavaScript and Node.js
Maintainers
Readme
pokefetch
Simple Pokémon data client for JavaScript and Node.js.
Fetch Pokémon, species, and type information with a clean and easy-to-use API.
Features
- Get Pokémon by name or ID
- Get species information
- Get type information
- Search Pokémon with pagination
- Promise-based API
- No dependencies
- ES Module support
Quick Start
import { getPokemon } from "pokefetch";
const pokemon = await getPokemon("pikachu");
console.log(pokemon);Output:
{
id: 25,
name: "pikachu",
height: 4,
weight: 60,
types: ["electric"],
abilities: ["static", "lightning-rod"],
sprite: "https://..."
}API
getPokemon(nameOrId)
Get Pokémon information by name or Pokédex ID.
import { getPokemon } from "pokefetch";
const charizard = await getPokemon("charizard");
const pikachu = await getPokemon(25);getSpecies(nameOrId)
Get species information.
import { getSpecies } from "pokefetch";
const species = await getSpecies("charizard");
console.log(species);Returns:
{
id: 6,
name: "charizard",
habitat: "mountain",
legendary: false,
mythical: false,
generation: "generation-i"
}getType(typeName)
Get Pokémon type information.
import { getType } from "pokefetch";
const fire = await getType("fire");
console.log(fire);search(limit, offset)
Search Pokémon with pagination.
import { search } from "pokefetch";
const pokemon = await search(10, 0);
console.log(pokemon);Error Handling
try {
const pokemon = await getPokemon("not-a-real-pokemon");
} catch (error) {
console.error(error.message);
}Requirements
- Node.js 18 or newer
Example
import { getPokemon } from "pokefetch";
const pokemon = await getPokemon("bulbasaur");
console.log(`${pokemon.name} is a ${pokemon.types.join(", ")} type Pokémon.`);License
MIT
