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 🙏

© 2024 – Pkg Stats / Ryan Hefner

pokeapi-typescript

v2.1.0

Published

Typescript SDK for PokeAPI (https://pokeapi.co)

Downloads

485

Readme

pokeapi-typescript

About

pokeapi-typescript is a fully-typed SDK for the PokeAPI using Promises, featuring an easy to manage cache which utilises Collections

Installation

Via yarn: yarn add pokeapi-typescript

Via npm: npm install pokeapi-typescript

Getting Started

To start using the PokeAPI, import the module. All available endpoints are mounted as static properties of the module.

// ES6 imports
import PokeAPI from "pokeapi-typescript";
// Node.js require
const PokeAPI = require("pokeapi-typescript");

Endpoints

Every endpoint documented in the PokeAPI Docs is available. By default, any data that is fetched will be cached in-memory.

.resolve()

PokeAPI.<Endpoint>.resolve() retrieves a resource, first checking the internal cache to see if it is available. If no cached resource exists, it will be fetched via the API.

By ID

// Using .then()
PokeAPI.Pokemon.resolve(25).then(result => console.log(result));

// Using async/await
const result = await PokeAPI.Pokemon.resolve(25);

By Name

// Using.then()
PokeAPI.Pokemon.resolve("pikachu").then(result => console.log(result));

// Using async/await
const result = await PokeAPI.Pokemon.resolve("pikachu");

.fetch()

PokeAPI.<Endpoint>.fetch() will always retrieve a resource via the API, updating any cached resources in the process.

By ID

// Using .then()
PokeAPI.Pokemon.fetch(25).then(result => console.log(result));

// Using async/await
const result = await PokeAPI.Pokemon.fetch(25);

By Name

// Using.then()
PokeAPI.Pokemon.fetch("pikachu").then(result => console.log(result));

// Using async/await
const result = await PokeAPI.Pokemon.fetch("pikachu");

.get()

PokeAPI.<Endpoint>.get() will always retrieve a cached resource, returning null if one could not be found. .get() is synchronous and does not return a Promise.

By ID

const result = PokeAPI.Pokemon.get(25);

By Name

const result = PokeAPI.Pokemon.get("pikachu");

.list()

PokeAPI.<Endpoint>.list() retrieves the IApiResourceList or INamedApiResourceList for an endpoint.

list() accepts two parameters for pagination

  • limit - Number of results to list. Default 20
  • offset - Index of result to start listing from. Default 0
// Fetch 1000 Pokemon (all) in a NamedApiResourceList
const resourceList = await PokeAPI.Pokemon.list(1000, 0);

resourceList.results will contain an array of IApiResource or INamedApiResource objects depending on the type of list.

.listAll()

PokeAPI.<Endpoint>.listAll() functions like the above, but will return the complete list for an endpoint. This is done by making two API calls.

// Fetch 1000 Pokemon (all) in a NamedApiResourceList
const completeResourceList = await PokeAPI.Pokemon.listAll();

Endpoint List

Berries

  • Berry
  • BerryFirmness
  • BerryFlavors

Contests

  • ContestType
  • ContestEffect
  • SuperContestEffect

Encounters

  • EncounterMethod
  • EncounterCondition
  • EncounterConditionValue

Evolution

  • EvolutionChain
  • EvolutionTrigger

Games

  • Generation
  • Pokedex
  • Version
  • VersionGroup

Items

  • Item
  • ItemAttribute
  • ItemCategory
  • ItemFlingEffect
  • ItemPocket
Locations
  • Location
  • LocationArea
  • PalParkArea
  • Region

Machines

  • Machine

Moves

  • Move
  • MoveAilment
  • MoveBattleStyle
  • MoveCategory
  • MoveDamageClass
  • MoveLearnMethod
  • MoveTarget

Pokemon

  • Ability
  • Characteristic
  • EggGroup
  • Gender
  • GrowthRate
  • Nature
  • PokeathlonStat
  • Pokemon
  • PokemonColor
  • PokemonForm
  • PokemonHabitat
  • PokemonShape
  • PokemonSpecies
  • Stat
  • Type

Utility

  • Language