pokedex-promise-v2
An easy way to use Pokéapi v2 with promises (or callbacks as of v3) in node.js
Table of Contents
Install
You can install with Npm!
npm install pokedex-promise-v2 --save
or with Yarn!
yarn add pokedex-promise-v2
Usage
var Pokedex = ;var P = ;
NOTE: Any function with the designation "ByName" can also be passed an integer ID. However, the functions with the designation "ById" can only be passed an integer ID. Refer to the pokeapi v2 docs to find out more about how the data is structured.
UPDATE: You can pass an array to each endpoint, it will retrive data for each array element. If you scroll down, you will find an example.
Example requests
P // with Promise ; P; P ;
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 😄. 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.
var Pokedex = ;var options = protocol: 'https' hostName: 'localhost:443' versionPath: '/api/v2/' cacheLimit: 100 * 1000 // 100s timeout: 5 * 1000 // 5svar P = options;
Endpoints
Berries
Use getBerryByName to return data about a specific berry.
P ;
Use getBerryFirmnessByName to return data about the firmness of a specific berry.
P ;
Use getBerryFlavorByName to return data about the flavor of a specific berry.
P ;
Array as a parameter example. It can be a mixed array. This method fetches data asynchronously. So it is quite fast 😄
P // response will be an Array containing 3 Objects // response.forEach((item) => {console.log(item.size)}) // 80,50,20
Contests
Use getContestTypeByName to return data about the effects of moves when used in contests.
P ;
Use getContestEffectById to return data about the effects of moves when used in contests.
P ;
Use getSuperContestEffectById to return data about the effects of moves when used in super contests.
P ;
Encounters
Use getEncounterMethodByName to return data about the conditions in which a trainer may encounter a pokemon in the wild.
P ;
Use getEncounterConditionByName to return data that affects which pokemon might appear in the wild.
P ;
Use getEncounterConditionValueByName to return data the various states that an encounter condition can have.
P ;
Evolution
Use getEvolutionChainById to return data evolution chains.
P ;
Use getEvolutionTriggerByName to return data about triggers which cause pokemon to evolve.
P ;
Games
Use getGenerationByName to return data about the different generations of pokemon games.
P ;
Use getPokedexByName to return data about specific types of pokedexes.
P ;
Use getVersionByName to return data about specific versions of pokemon games.
P ;
Use getVersionGroupByName to return data about specific version groups of pokemon games.
P ;
Items
Use getItemByName to return data about specific items.
P ;
Use getItemAttributeByName to return data about specific item attribute.
P ;
Use getItemCategoryByName to return data about specific item category.
P ;
Use getItemFlingEffectByName to return data about specific item fling effect.
P ;
Use getItemPocketByName to return data about specific pockets in a players bag.
P ;
Machines
Use getMachineById to return data about specific machine.
P ;
Moves
Use getMoveByName to return data about specific pokemon move.
P ;
Use getMoveAilmentByName to return data about specific pokemon move ailment.
P ;
Use getMoveBattleStyleByName to return data about specific pokemon move battle style.
P ;
Use getMoveCategoryByName to return data about specific pokemon move category.
P ;
Use getMoveDamageClassByName to return data about specific pokemon damage class.
P ;
Use getMoveLearnMethodByName to return data about specific pokemon learn method.
P ;
Use getMoveTargetByName to return data about specific pokemon move target.
P ;
Locations
Use getLocationByName to return data about specific pokemon location.
P ;
Use getLocationAreaByName to return data about specific pokemon location area.
P ;
Use getPalParkAreaByName to return data about specific pokemon pal park area.
P ;
Use getRegionByName to return data about specific pokemon region.
P ;
Pokemon
Use getAbilityByName to return data about specific pokemon ability.
P ;
Use getCharacteristicById to return data about specific pokemon characteristic.
P ;
Use getEggGroupByName to return data about specific pokemon egg group.
P ;
Use getGenderByName to return data about specific pokemon gender.
P ;
Use getGrowthRateByName to return data about specific pokemon growth rate.
P ;
Use getNatureByName to return data about specific pokemon nature.
P ;
Use getPokeathlonStatByName to return data about specific pokeathon stat.
P ;
Use getPokemonByName to return data about specific pokemon.
P ;
Use getPokemonColorByName to return data about specific pokemon color.
P ;
Use getPokemonFormByName to return data about specific pokemon form.
P ;
Use getPokemonHabitatByName to return data about specific pokemon habitat.
P ;
Use getPokemonShapeByName to return data about specific pokemon shape.
P ;
Use getPokemonSpeciesByName to return data about specific pokemon species.
P ;
Use getStatByName to return data about specific pokemon stat.
P ;
Use getTypeByName to return data about specific pokemon type.
P ;
Utility
Use getLanguageByName to return data about specific pokemon language.
P ;
Custom URLs and paths
Use resource to return data about any URL or path.
P ; P ;
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
This is what you will get:
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()