Installation of @atosjs/pokemon
npm
Terminal
npm install @atosjs/pokemonInterface with the PokéAPI for data collection:
The PokeDex class from the @atosjs/pokemon resource package allows you to fetch complete Pokémon data using id or name. It structures the API response to make the information easier to consume, returning data such as name, types, abilities, stats, sprite (image), height, weight, evolution chain, and a description.
Basic Usage
index.js
const { PokeDex } = require("@atosjs/pokemon");
const pokedex = new PokeDex();
(async () => {
// Fetching Pokémon by name
const pikachu = await pokedex.fetch({ name: "pikachu" });
// All Pokémon information
console.log("Pikachu:", pikachu);
// Displaying the sprite
console.log("Sprite:", pikachu.sprite);
})();The example above demonstrates how to instantiate the PokeDex class and fetch the Pokémon “pikachu”. You can also fetch using id or even arrays of values.
Expected Result
Terminal
Pikachu: {
name: 'pikachu',
id: 25,
type: [ 'electric' ],
abilities: [ 'static', 'lightning-rod' ],
sprite: 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/25.png',
height: 4,
weight: 60,
base_stats: {
hp: 35,
attack: 55,
defense: 40,
'special-attack': 50,
'special-defense': 50,
speed: 90
},
evolution_chain: { url: 'https://pokeapi.co/api/v2/evolution-chain/10/' },
description: 'When several of these POKéMON gather, their electricity could build and cause lightning storms.'
}
Sprite: https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/25.pngMultiple Queries
multi-fetch.js
const { PokeDex } = require("@atosjs/pokemon");
const pokedex = new PokeDex();
(async () => {
// Fetching multiple Pokémon using id
const pokemonList = await pokedex.fetch({ id: [1, 4, 7] });
console.log("Pokémon list:", pokemonList);
// Or using names
const anotherList = await pokedex.fetch({ name: ["bulbasaur", "charmander", "squirtle"] });
console.log("Another list:", anotherList);
})();You can also pass arrays with multiple values for id or name, and you will get an array with the structured data of each Pokémon.
🧩 Return Structure (PokeData)
The structured response returned by the PokeDex class has the following format:
| Field | Type | Description |
|---|---|---|
name | string | Pokémon’s name. |
id | number | Pokémon’s national ID. |
type | string[] | Pokémon’s types. |
abilities | string[] | Pokémon’s abilities. |
sprite | string | URL of the front image (sprite). |
height | number | Height in decimeters. |
weight | number | Weight in hectograms. |
base_stats | Record<string,number> | Base stats (HP, attack, defense, etc.). |
evolution_chain | { url: string } | URL of the evolution chain. |
description | string | Descriptive text taken from the API (in English). |
Last updated on: