How I can get level of Pokemon GO user?
Opened this issue · 1 comments
alexqill commented
Hi, please help me, how I can get level of Pokemon GO user?
LemonDew commented
You need to call the "GetInventory" API call.
Then you can get more information about the player, please see:
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);
}
});