Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How I can get level of Pokemon GO user? #227

Open
alexqill opened this issue Aug 9, 2016 · 1 comment
Open

How I can get level of Pokemon GO user? #227

alexqill opened this issue Aug 9, 2016 · 1 comment

Comments

@alexqill
Copy link

alexqill commented Aug 9, 2016

Hi, please help me, how I can get level of Pokemon GO user?

@LemonDew
Copy link

LemonDew commented Aug 11, 2016

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);
        }
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants