Pokemon-GO-node-api
Pokemon-GO-node-api copied to clipboard
How can I get a list of Pokemon a user has?
Just got this installed and working, curious how I could go about pulling the data for the current pokemon a user has kinda like:
Charizard - 1200 CP - 156 HP - 2500 Candy - 3 Candies - Move 1 (Damage) - Move 2 (Damage)
Or any of that information, is this possible?
Thanks
You need to call "GetInventory", like so:
api.GetInventory(function (err, inventory) {
if (!err) {
var cleanedInventory = { player_stats: null, eggs : [], pokemon: [], items: [] };
for (var i = 0; i < inventory.inventory_delta.inventory_items.length; i++) {
var inventory_item_data = inventory.inventory_delta.inventory_items[i].inventory_item_data;
// Check for pokemon.
if (inventory_item_data.pokemon) {
var pokemon = inventory_item_data.pokemon;
if (pokemon.is_egg) {
console.log(' [E] ' + pokemon.egg_km_walked_target + ' Egg');
cleanedInventory.eggs.push(pokemon);
} else {
var pokedexInfo = api.pokemonlist[parseInt(pokemon.pokemon_id) - 1];
console.log(' [P] ' + pokedexInfo.name + ' - ' + pokemon.cp + ' CP');
cleanedInventory.pokemon.push(pokemon);
}
}
// Check for player stats.
if (inventory_item_data.player_stats) {
var player = inventory_item_data.player_stats;
console.log(' [PL] Level ' + player.level + ' - ' + player.unique_pokedex_entries + ' Unique Pokemon');
cleanedInventory.player_stats = player;
}
// Check for item.
if (inventory_item_data.item) {
var item = inventory_item_data.item;
console.log(' [I] ' + item.item_id + ' - ' + item.count);
cleanedInventory.items.push(item);
}
}
callback(cleanedInventory);
}
});