promisemon
v1.0.4
Published
The ultimate pokedex you will ever need
Downloads
4
Maintainers
Readme
promisemon
Maintainers: Ashay
The best and easiest way to use Pokéapi v2 with promises in node.js
Table of Contents
Install
npm install promisemon --save
yarn add promisemon
Usage
var Pokedex = require('promisemon');
var P = new Pokedex();
NOTE: Refer to the pokeapi v2 docs to find out more about how the data is structured.
P.getPokemon('eevee') // with Promise
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Configuration
Pass an Object to Pokedex in order to configure it. Available options: protocol
, hostName
, versionPath
, cacheLimit
in ms, timeout
in ms.
Any option is optional :smile:. If no Object is passed, the Pokedex will be initialized to grab data from pokeapi.co using http with 20 seconds timeout and caching resources for 11 days. HTTPS is the default protocol.
var Pokedex = require('promisemon');
var options = {
protocol: 'https',
hostName: 'localhost:443',
versionPath: '/api/v2/',
cacheLimit: 100 * 1000, // 100s
timeout: 5 * 1000 // 5s
}
var P = new Pokedex(options);
Endpoints
Berries
Use getBerry to return data about a specific berry.
P.getBerry('cheri')
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getBerryFirmness to return data about the firmness of a specific berry.
P.getBerryFirmness('very-soft')
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getBerryFlavor to return data about the flavor of a specific berry.
P.getBerryFlavor('spicy')
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Contests
Use getContestType to return data about the effects of moves when used in contests.
P.getContestType('cool')
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getContestEffect to return data about the effects of moves when used in contests.
P.getContestType(1)
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getSuperContestEffect to return data about the effects of moves when used in super contests.
P.getSuperContestType(1)
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Encounters
Use getEncounterMethod to return data about the conditions in which a trainer may encounter a pokemon in the wild.
P.getEncounterMethod("walk")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getEncounterCondition to return data that affects which pokemon might appear in the wild.
P.getEncounterCondition("swarm")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getEncounterConditionValue to return data the various states that an encounter condition can have.
P.getEncounterConditionValue("swarm-yes")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Evolution
Use getEvolutionChain to return data evolution chains.
P.getEvolutionChain(1)
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getEvolutionTrigger to return data about triggers which cause pokemon to evolve.
P.getEvolutionTrigger("level-up")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Games
Use getGeneration to return data about the different generations of pokemon games.
P.getGeneration("generation-i")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getPokedex to return data about specific types of pokedexes.
P.getPokedex("kanto")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getVersion to return data about specific versions of pokemon games.
P.getVersion("red")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getVersionGroup to return data about specific version groups of pokemon games.
P.getVersionGroup("red-blue")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Items
Use getItem to return data about specific items.
P.getItem("master-ball")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getItemAttribute to return data about specific item attribute.
P.getItemAttribute("countable")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getItemCategory to return data about specific item category.
P.getItemCategory("stat-boosts")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getItemFlingEffect to return data about specific item fling effect.
P.getItemFlingEffect("badly-poison")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getItemPocket to return data about specific pockets in a players bag.
P.getItemPocket("misc")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Machines
Use getMachine to return data about specific machine.
P.getMachine(2)
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Moves
Use getMove to return data about specific pokemon move.
P.getMove("pound")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getMoveAilment to return data about specific pokemon move ailment.
P.getMoveAilment("paralysis")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getMoveBattleStyle to return data about specific pokemon move battle style.
P.getMoveBattleStyle("attack")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getMoveCategory to return data about specific pokemon move category.
P.getMoveCategory("ailment")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getMoveDamageClass to return data about specific pokemon damage class.
P.getMoveDamageClass("status")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getMoveLearnMethod to return data about specific pokemon learn method.
P.getMoveLearnMethod("level-up")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getMoveTarget to return data about specific pokemon move target.
P.getMoveTarget("specific-move")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Locations
Use getLocation to return data about specific pokemon location.
P.getLocation("sinnoh")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getLocationArea to return data about specific pokemon location area.
P.getLocationArea("canalave-city-area")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getPalParkArea to return data about specific pokemon pal park area.
P.getPalParkArea("forest")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getRegion to return data about specific pokemon region.
P.getRegion("kanto")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Pokemon
Use getAbility to return data about specific pokemon ability.
P.getAbility("stench")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getCharacteristic to return data about specific pokemon characteristic.
P.getCharacteristic(1)
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getEggGroup to return data about specific pokemon egg group.
P.getEggGroup("monster")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getGender to return data about specific pokemon gender.
P.getGender("female")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getGrowthRate to return data about specific pokemon growth rate.
P.getGrowthRate("slow")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getNature to return data about specific pokemon nature.
P.getNature("bold")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getPokeathlonStat to return data about specific pokeathon stat.
P.getPokeathlonStat("speed")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getPokemon to return data about specific pokemon.
P.getPokemon("butterfree")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getPokemonColor to return data about specific pokemon color.
P.getPokemonColor("black")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getPokemonForm to return data about specific pokemon form.
P.getPokemonForm("wormadam-plant")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getPokemonHabitat to return data about specific pokemon habitat.
P.getPokemonHabitat("grottes")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getPokemonShape to return data about specific pokemon shape.
P.getPokemonShape("ball")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getPokemonSpecies to return data about specific pokemon species.
P.getPokemonSpecies("wormadam")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getStat to return data about specific pokemon stat.
P.getStat("attack")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Use getType to return data about specific pokemon type.
P.getType("ground")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Utility
Use getLanguage to return data about specific pokemon language.
P.getLanguage("ja")
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log('There was an ERROR: ', error);
});
Root Endpoints
For each root endpoint we provide a method to get all the items contained by that endpoint. By default the method will return every item in the endpoint. If you want you can configure its offset and limit.
offset
is where to start. The first item that you will get. Default0
limit
is how many items you want to list. Default100000
TIP: Do not pass any config Object to your call, since you will get every item and everything will be cached to your RAM.
This call will get the list of pokemon between ID 34 and ID 44
var interval = {
limit: 10,
offset: 34
}
P.getPokemonsList(interval)
.then(function(response) {
console.log(response);
})
This is what you will get:
{
"count": 811,
"next": "https://pokeapi.co:443/api/v2/pokemon/?limit=11&offset=44",
"previous": "https://pokeapi.co:443/api/v2/pokemon/?limit=11&offset=22",
"results": [
{
"url": "https://pokeapi.co:443/api/v2/pokemon/34/",
"name": "nidoking"
},
{
"url": "https://pokeapi.co:443/api/v2/pokemon/35/",
"name": "clefairy"
},
{
"url": "...",
"name": "..."
},
{
"url": "https://pokeapi.co:443/api/v2/pokemon/44/",
"name": "gloom"
}
]
}
List of supported root endpoints
- .getEndpointsList()
- .getBerriesList()
- .getBerriesFirmnesssList()
- .getBerriesFlavorsList()
- .getContestTypesList()
- .getContestEffectsList()
- .getSuperContestEffectsList()
- .getEncounterMethodsList()
- .getEncounterConditionsList()
- .getEncounterConditionValuesList()
- .getEvolutionChainsList()
- .getEvolutionTriggersList()
- .getGenerationsList()
- .getPokedexsList()
- .getVersionsList()
- .getVersionGroupsList()
- .getItemsList()
- .getItemAttributesList()
- .getItemCategoriesList()
- .getItemFlingEffectsList()
- .getItemPocketsList()
- .getMachinesList()
- .getMovesList()
- .getMoveAilmentsList()
- .getMoveBattleStylesList()
- .getMoveCategoriesList()
- .getMoveDamageClassesList()
- .getMoveLearnMethodsList()
- .getMoveTar()
- .getsList()
- .getLocationsList()
- .getLocationAreasList()
- .getPalParkAreasList()
- .getRegionsList()
- .getAbilitiesList()
- .getCharacteristicsList()
- .getEggGroupsList()
- .getGendersList()
- .getGrowthRatesList()
- .getNaturesList()
- .getPokeathlonStatsList()
- .getPokemonsList()
- .getPokemonColorsList()
- .getPokemonFormsList()
- .getPokemonHabitatsList()
- .getPokemonShapesList()
- .getPokemonSpeciesList()
- .getStatsList()
- .getTypesList()
- .getLanguagesList()