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

pokeapi

v0.0.1

Published

A simple client for pokeapi.co

Downloads

37

Readme

PokeApi

Build Status Version Licens

A light-weight promise-based REST client for accessing pokeapi.co, usable from node.js or in the browser (through the magic of browserify).

Usage

var PokeApi = require('pokeapi');
var api = PokeApi.v1();

api.get('pokemon', 1).then(function(bulbasaur) {
    console.log("Here's Bulbasaur:", bulbasaur);
	api.get(bulbasaur.moves).then(function(moves) {
	    console.log("Full move list:" + moves);
    })
}, function(err) {
    console.log('ERROR', err);
});

Fetching a resource by ID

Resources can be fetched by supplying the resource name and the ID of the resource.

// returns a promise for a single object
api.get('pokemon', 1)
// the ID can also be a string
api.get('pokemon', '1')

// returns a promise for an array of objects
api.get('pokemon', '1,2,3,7-9')

Fetching a resource by resource_uri

You can also get resources by supplying an object with a resource_uri property, or an array of such objects:

// returns a promise for a single object
api.get({ resource_uri: '/api/v1/pokemon/1/' })

// returns a promise for an array of objects
api.get([ 
    { resource_uri: '/api/v1/pokemon/1/' }, 
    { resource_uri: '/api/v1/pokemon/2/' }
]);

This is particularly useful since all references to other objects will have this format, making it possible to do things like:

api.get('pokemon', 1).then(function(bulbasaur) {
    console.log("Here's Bulbasaur:", bulbasaur);
	api.get(bulbasaur.moves).then(function(moves) {
	    console.log("Full move list:" + moves);
    })
});

Local client

You can run PokeApi in 'offline' mode, where data is read from locally stored data files rather than fetched from pokeapi.co on every request. This makes sense in cases when you're working with smaller sets of data that you don't expect to change a whole lot, i.e. move types. It's also very useful for working with data inside the browser without having to bother with setting up an AJAX proxy.

The data objects should have the same format as the output from api.get() (the CLI command is a good way to export the data). You can specify muliple data files.

// assuming that types.json and moves.json exists
var types = require('./types');
var moves = require('./moves');

// creating a local client that can be queried for type and move data
var api = PokeApi.local(types, moves).v1();

Command-line Interface

PokeApi includes a simple CLI:

> npm install -g pokeapi
...

> pokeapi get type 1
{"created":"2013-11-02T12:08:58.787000","id":1,"ineffective":[{"name":"rock","resource_uri":"/api/v1/type/6/"},{"name":"steel","resource_uri":"/api/v1/type/9/"}],"modified":"

Running PokeApi in the browser

PokeApi can be run in the client using browserify. In order to query the pokeapi.co server you proably need to set up an AJAX proxy on your own. If you are running express this is pretty straightforward:

var express = require('express');
var request = require('request');

var app = express();

app.get('/api/*', function(req, res) {
    request('http://pokeapi.co' + req.path).pipe(res);
});

When setting up the client you then need to tell it to connect to your own server instead of pokeapi.co:

var api = PokeApi.host('http://myhost').v1()