Skip to Content

Installation of @atosjs/pokemon

Terminal
npm install @atosjs/pokemon
Interface 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.png

Multiple 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:

FieldTypeDescription
namestringPokémon’s name.
idnumberPokémon’s national ID.
typestring[]Pokémon’s types.
abilitiesstring[]Pokémon’s abilities.
spritestringURL of the front image (sprite).
heightnumberHeight in decimeters.
weightnumberWeight in hectograms.
base_statsRecord<string,number>Base stats (HP, attack, defense, etc.).
evolution_chain{ url: string }URL of the evolution chain.
descriptionstringDescriptive text taken from the API (in English).
Last updated on: