-
Notifications
You must be signed in to change notification settings - Fork 445
Usage
Before any API requests can be executed, it is necessary to set a position and then to login. The coordinates are latitude, longitude and altitude. For the login, it is possible to use "google" so your google account or "ptc" (Pokemon Trainer Club).
api = pgoapi.PGoApi()
api.set_position(40.7127837, -74.005941, 0.0)
api.login('ptc', 'your_username', 'your_secure_password')
api.login will of course return True or False.
After a successful login, API calls can be made. There are two ways to do this.
The first one is very simple and can be executed directly over the api object:
...
response = api.get_player()
A more complex way which is thread-safe and supports chaining (more than one subrequest in a API call) has to be done over a separate request object, which can be created over api.create_request():
...
req = api.create_request()
req.get_player()
req.get_inventory()
response = req.call()
The output is currently just a dictionary which can be easily dumped/printed:
...
import pprint
print('Response dictionary:\n\r{}'.format(pprint.PrettyPrinter(indent=4).pformat(response)))
Different API calls to the Pokemon Go server require certain arguments, like which Pokemon you want to release. In the API reference, all calls are described with the possible input arguments.
...
api.release_pokemon(pokemon_id = <your pokemonid>)
If there are more complex types, like repeated fields and subtypes (which have further arguments) they can be specified by lists and dictionaries.
...
api.get_map_objects(
latitude = lat,
longitude = lng,
since_timestamp_ms = [0, 0, 0, 0],
cell_id = [<cell_id_1>, <cell_id_2>, <cell_id_3>, <cell_id_4>]
)
...
api.set_avatar(
player_avatar = {
skin: "<your_input>", ...
}
)
pokecli.py is a small pgoapi example script which shows the generic usage of pgoapi with few RPC calls.
usage: pokecli.py [-h] -a AUTH_SERVICE -u USERNAME -p PASSWORD -l LOCATION [-d] [-t]
optional arguments:
-h, --help show this help message and exit
-a AUTH_SERVICE, --auth_service AUTH_SERVICE Auth Service ('ptc' or 'google')
-u USERNAME, --username USERNAME Username
-p PASSWORD, --password PASSWORD Password
-l LOCATION, --location LOCATION Location
-d, --debug Debug Mode
-t, --test Only parse the specified location
Build and run container:
docker build -t pokecli .
docker run pokecli
Optionally create an alias:
alias pokecli='docker run pokecli'
- add_fort_modifier
- attack_gym
- catch_pokemon
- check_awarded_badges
- check_codename_available
- claim_codename
- collect_daily_bonus
- collect_daily_defender_bonus
- disk_encounter
- download_item_templates
- download_remote_config_version
- download_settings
- echo
- encounter
- encounter_tutorial_complete
- equip_badge
- evolve_pokemon
- fort_deploy_pokemon
- fort_details
- fort_recall_pokemon
- fort_search
- get_asset_digest
- get_download_urls
- get_gym_details
- get_hatched_eggs
- get_incense_pokemon
- get_inventory
- get_map_objects
- get_player
- get_player_profile
- get_suggested_codenames
- incense_encounter
- level_up_rewards
- mark_tutorial_complete
- nickname_pokemon
- player_update
- recycle_inventory_item
- release_pokemon
- set_avatar
- set_contact_settings
- set_favorite_pokemon
- set_player_team
- sfida_action_log
- start_gym_battle
- upgrade_pokemon
- use_incense
- use_item_capture
- use_item_egg_incubator
- use_item_gym
- use_item_potion
- use_item_revive
- use_item_xp_boost
buy_gem_packbuy_item_packdebug_delete_playerdebug_update_inventoryget_item_packitem_useload_spawn_pointssfida_actionsfida_capturesfida_certificationsfida_dowsersfida_registrationsfida_updatetrade_offertrade_responsetrade_resulttrade_searchuse_item_flee