npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pokemon-app-engine

v1.0.1

Published

Simple pokemon api engine powered by pokeapi

Readme

PokemonAppEngine

A lightweight, type-safe TypeScript engine for fetching Pokémon data from the PokéAPI.

Features

  • 🎯 Fully Typed - TypeScript interfaces for all Pokémon data
  • 🚀 Simple API - Clean, intuitive methods for fetching Pokémon data
  • 📦 Lightweight - No dependencies, just native fetch
  • 🔄 Pagination Support - Built-in pagination for list endpoints
  • Modern - Uses async/await and ES modules

Installation

npm install pokemon-app-engine
# or
yarn add pokemon-app-engine
# or
pnpm add pokemon-app-engine

Usage

Basic Setup

import { PokemonAppEngine } from 'pokemon-app-engine';

const engine = new PokemonAppEngine();

Fetch a Pokémon

Get detailed information about a specific Pokémon by ID or name:

// By ID
const pikachu = await engine.getBy(25);

// By name
const charizard = await engine.getBy('charizard');

console.log(pikachu.name); // "pikachu"
console.log(pikachu.types); // [{ slot: 1, type: { name: "electric", url: "..." } }]
console.log(pikachu.stats); // [{ base_stat: 35, effort: 0, stat: {...} }, ...]

Fetch Pokémon Species

Get species-specific information including evolution chain, habitat, and flavor text:

const species = await engine.getSpeciesBy('pikachu');

console.log(species.is_legendary); // false
console.log(species.habitat.name); // "forest"
console.log(species.evolution_chain.url); // "https://pokeapi.co/api/v2/evolution-chain/10/"

Fetch Pokémon Types

Get type information including damage relations and Pokémon of that type:

const electricType = await engine.getTypeBy('electric');

console.log(electricType.damage_relations.double_damage_to);
// [{ name: "water", url: "..." }, { name: "flying", url: "..." }]

console.log(electricType.pokemon);
// [{ slot: 1, pokemon: { name: "pikachu", url: "..." } }, ...]

List Pokémon (Paginated)

Fetch a paginated list of Pokémon:

// Get first 20 Pokémon
const pokemonList = await engine.getPokemons();

// Get next 20 Pokémon
const nextPage = await engine.getPokemons({ offset: 20, limit: 20 });

// Get 50 Pokémon starting from position 100
const customPage = await engine.getPokemons({ offset: 100, limit: 50 });

console.log(pokemonList.count); // Total count (e.g., 1302)
console.log(pokemonList.results); // Array of { name, url }
console.log(pokemonList.next); // URL to next page
console.log(pokemonList.previous); // URL to previous page

List All Types

Get all available Pokémon types:

const types = await engine.getTypes();

console.log(types.results);
// [
//   { name: "normal", url: "..." },
//   { name: "fighting", url: "..." },
//   { name: "flying", url: "..." },
//   ...
// ]

List All Generations

Get all Pokémon generations:

const generations = await engine.getGenerations();

console.log(generations.results);
// [
//   { name: "generation-i", url: "..." },
//   { name: "generation-ii", url: "..." },
//   ...
// ]

List All Species (Paginated)

Fetch a paginated list of Pokémon species:

const speciesList = await engine.getSpecies({ offset: 0, limit: 50 });

console.log(speciesList.results);
// [{ name: "bulbasaur", url: "..." }, ...]

List All Abilities (Paginated)

Fetch a paginated list of abilities:

const abilities = await engine.getAbilities({ offset: 0, limit: 50 });

console.log(abilities.results);
// [{ name: "stench", url: "..." }, { name: "drizzle", url: "..." }, ...]

Generic GET Request

For any custom endpoint not covered by the methods above:

import { Ability } from 'pokemon-app-engine';

// Fetch a specific ability
const overgrow = await engine.get<Ability>('https://pokeapi.co/api/v2/ability/65');

console.log(overgrow.name); // "overgrow"
console.log(overgrow.effect_entries[0].short_effect);

API Reference

Methods

| Method | Parameters | Returns | Description | |--------|-----------|---------|-------------| | getBy(id) | number \| string | Promise<Pokemon> | Fetch Pokémon by ID or name | | getSpeciesBy(id) | number \| string | Promise<Species> | Fetch species by ID or name | | getTypeBy(id) | number \| string | Promise<PokemonType> | Fetch type by ID or name | | getPokemons(options?) | GetPaginatedOptions? | Promise<PaginatedResponse<Raw>> | Fetch paginated Pokémon list | | getSpecies(options?) | GetPaginatedOptions? | Promise<PaginatedResponse<Raw>> | Fetch paginated species list | | getAbilities(options?) | GetPaginatedOptions? | Promise<PaginatedResponse<Raw>> | Fetch paginated abilities list | | getTypes() | - | Promise<PaginatedResponse<Raw>> | Fetch all types | | getGenerations() | - | Promise<PaginatedResponse<Raw>> | Fetch all generations | | get<T>(url) | string | Promise<T> | Generic GET request |

Examples

Build a Pokédex

const engine = new PokemonAppEngine();

// Fetch first 151 Pokémon (Gen 1)
const gen1 = await engine.getPokemons({ offset: 0, limit: 151 });

// Fetch detailed data for each
const pokemonDetails = await Promise.all(
  gen1.results.map(p => engine.getBy(p.name))
);

console.log(pokemonDetails.map(p => ({
  name: p.name,
  types: p.types.map(t => t.type.name),
  stats: p.stats.find(s => s.stat.name === 'hp')?.base_stat
})));

Find All Fire-type Pokémon

const fireType = await engine.getTypeBy('fire');

console.log(`There are ${fireType.pokemon.length} Fire-type Pokémon`);
console.log(fireType.pokemon.map(p => p.pokemon.name));

Check Legendary Status

const mew = await engine.getSpeciesBy('mew');
const pikachu = await engine.getSpeciesBy('pikachu');

console.log(`Mew is legendary: ${mew.is_legendary}`); // true
console.log(`Pikachu is legendary: ${pikachu.is_legendary}`); // false

For Developers

Running Tests

Run the unit tests:

npm run test

Development Setup

  1. Clone the repository
  2. Install dependencies:
    npm install
  3. Make your changes
  4. Run tests to ensure everything works:
    npm run test

Credits

Powered by PokéAPI - The RESTful Pokémon API.

License

MIT