pokeapi.co wrapper. Details about the api can be found here: http://pokeapi.co/docs/
Install
$ npm install --save pkmn
Usage
var Pkmn = ;var p = ;
Get
All methods return a bluebird promise.
.get
requires two arguments, a resource
and an id
. id
can be a string
, number
, or array
.
p ; p // logs [{name: 'Bulbasaur' ...}, {name: 'Mew'...}]
Errors and responses from the pokeapi that are not of status code 200 will be rejected.
p // logs [Error] 404
Too few arguments to .get
also throws an error. All resources except pokedex
require an id
argument to passed to .get
with them.
p // doesn't log // logs [Error] id argument required p // logs the pokedex
The full list of valid resources is:
pokedex, pokemon, egg, type, description, move, ability, sprite, game
Additionally, .get
can take a resource_id
as an argument. This is useful because most responses from pokeapi will have have a resource_id
field. For example, a pokemon will come with a list of moves, each move contains a resource_id
that you can pass directly to .get
to retrieve the details of that move.
p// ...
Convenience Methods
All valid resource argumets to .get
also have convenience methods:
pppp // etc...
The full list of api resources can obtained from the api via .api
p
License
MIT © Stephan Tabor