GithubHelp home page GithubHelp logo

pokemongo-api's Introduction

Pokemon Go API for Python

Code Health Build Status

Why use this API?

This is arguably one of the cleanest python API's out there. It is our hope that this codebase is easily understood and very readable. We actively stay away from reflection, because actively managed calls provide a nicer experience than digging through protobufs. Development is currently active, so feel free to contribute any requests or functionality you think is missing.

Important note: libencrypt.so or encrypt.dll is needed in order for complete functionality. Minor calls such as getProfile will still work without this. We do not provide this library due to copyright issues. However, if you know where to look, you should be able to be able to find either the binaries or the source.

Installation

Install this package via pip i.e pip install git+git://github.com/rubenvereecken/pokemongo-api@master Alternatively, clone this and use pip install .

To get newest, run pip install git+git://github.com/rubenvereecken/pokemongo-api@master --upgrade

Implementation

Trainer is a general purpose class meant to encapsulate basic functons. We recommend that you inherit from this class to provide your specific usecase. We understand that Trainer is not as fully flushed out as it could be- it is meant to be a stub for building more complex logic. e.g.

class Map(Trainer):
    """My beautiful map implementation"""

    def fillWebSocketsForRealtimeStuffOrSomethingLikeThat(self):
        """Fill websockets with profile data or something.
        I don't know. The world is your oyster."""
        profile = self.session.getProfile()
        ...

or

class Bot(Trainer):
    """Such bot, much cheat."""

    def catchAllThePokemonOrSomething(self):
        """Whatever it is botters do"""
        ...

Feel free to also ignore trainer and call session functions directly.

Features

Our current implementaion covers most of the basics of gameplay. The following methods are availible:

Description function
Get Profile (Avatar, team etc..) getProfile()
Get Eggs getEggs()
Get Inventory getInventory()
Get Badges getBadges()
Get Settings getDownloadSettings()
Get Location getMapObjects(radius=10, bothDirections=True)
Get Location getFortSearch(fort)
Get details about fort (image, text etc..) getFortDetails(fort)
Get encounter (akin to tapping a pokemon) encounterPokemon(pokemon)
Upon Encounter, try and catch catchPokemon(pokemon, pokeball=items.POKE_BALL, normalized_reticle_size=1.950, hit_pokemon=True, spin_modifier=0.850, normalized_hit_position=1.0)
Use a razz berry or the like useItemCapture(item_id, pokemon)
Use a Potion (Hyper potion, super, etc..) useItemPotion(item_id, pokemon)
Use a Revive (Max revive etc as well) useItemRevive(item_id, pokemon)
Evolve Pokemon (check for candies first) evolvePokemon(pokemon)
'Transfers' a pokemon. releasePokemon(pokemon)
Check for level up and apply getLevelUp(newLevel)
Use a lucky egg useXpBoost()
Throw away items recycleItem(item_id, count)
set an Egg into an incubator setEgg(item, pokemon)
Set the name of a given pokemon nicknamePokemon(pokemon, nickname)
Set Pokemon as favorite setFavoritePokemon(pokemon, is_favorite)
Upgrade a Pokemon's CP upgradePokemon(pokemon)
Choose player's team - BLUE,RED, or YELLOW. setPlayerTeam(team)

Every method has been tested locally. Automated units tests are needed, and are currently in the works. Pull requests are encouraged.

Demo

demo.py includes a demo of the API.

➜  python demo.py -a "google" -u "[email protected]" -p "thepassword" -l "The Atlantic Ocean" -e"libencrypt.so"

2016-07-17 16:26:59,947 - INFO - Creating Google session for [email protected]
2016-07-17 16:26:59,953 - INFO - Starting new HTTPS connection (1): android.clients.google.com
2016-07-17 16:27:00,362 - INFO - Starting new HTTPS connection (1): android.clients.google.com
2016-07-17 16:27:00,789 - INFO - Location: The Atlantic Ocean
2016-07-17 16:27:00,789 - INFO - Coordinates: 51.01 7.12 0.0
2016-07-17 16:27:00,793 - INFO - Starting new HTTPS connection (1): pgorelease.nianticlabs.com
2016-07-17 16:27:01,633 - INFO - creation_time: 3341800000
team: 3
avatar {
  hair: 1
  shirt: 1
  pants: 1
  hat: 1
  shoes: 1
  eyes: 1
  backpack: 1
}
max_pokemon_storage: 250
max_item_storage: 400
daily_bonus {
  next_defender_bonus_collect_timestamp_ms: 4106877052
}
currency {
  type: "STARDUST"
  quantity: 9001
}

This is achieved with minimal coding effort on the client's part (extract from demo.py):

  # ... Blabla define the parser
  if args.auth == 'ptc':
      session = api.createPTCSession(args.username, args.password, args.location)
  elif args.auth == 'google':
      session = api.createGoogleSession(args.username, args.password, args.location)

  if session: # do stuff
      profile = session.getProfile()
      logging.info(profile)

Contribution

Hell yeah! I'm on Slack too (want an invite?) if you want to have a quick chat.

I welcome all PRs but for big changes it'd be best to open an issue so I have some idea of what's going on. This thing is under heavy development after all.

Protocol

We currently use AeonLucid's Pokemon Go Protobuf protocol.

Contributors

Thanks @dmadisetti for keeping this baby up and giving it the love it deserves, along with everybody else who took the time to set up a PR!

pokemongo-api's People

Contributors

adithyaphilip avatar dmadisetti avatar dnsblah avatar dracoblue avatar egguy avatar hilburn avatar iamcarbonman avatar jmaygarden avatar kazukionodera avatar mcteo avatar mhozza avatar p0psicles avatar qazbnm456 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pokemongo-api's Issues

Error in pokedex.py

Hello, I don't know why I receive the following error when executing demo.py:
Traceback (most recent call last):
File "demo.py", line 8, in
from api import PokeAuthSession
File "C:\Users\Selarep\Desktop\pokemongo-api-master\pogo\api.py", line 7, in
from session import PogoSession
File "C:\Users\Selarep\Desktop\pokemongo-api-master\pogo\session.py", line 22, in
from inventory import Inventory, items
File "C:\Users\Selarep\Desktop\pokemongo-api-master\pogo\inventory.py", line 1, in
from pokedex import pokedex
File "C:\Users\Selarep\Desktop\pokemongo-api-master\pogo\pokedex.py", line 272, in
pokedex = Pokedex()
File "C:\Users\Selarep\Desktop\pokemongo-api-master\pogo\pokedex.py", line 164, in init
super(dict, self).init(self)
TypeError: object.init() takes no parameters

Can anyone help me, please?

Are there tests?

In the readme you state: "Every method has been tested" but I don't see any tests in the repo.

If we had automated tests for something like this, using something like travis, it would be super handy to know when niantic's server responses change and make sure that contributions don't break things.

Refresh Token - Status code 102

Hi all, is there someone who built-in a token refresh ?

When I get status_code 102, I raise an exception to reauthenticate.
However this is not working..

On all other issue's a reauthentication works fine tho.

[Request] Gym info method

It would be nice to have a method to get info on a specific gym.
The id, latitude, longitude, ownership, and gym points are included in getMapObjects() so, is there any way to have :

  • gym name
  • list of pokemons on the gym, with :
    • pokemon id
    • pokemon CP
    • number of wins
  • more info?

Thanks for this great work!

MapObjects lack of pokemon and other issue

Hi all,

is it just me or are there soo much less pokemons on the map (meaning wild_pokemon and catchable_pokemon)
Is there any way to find more pokemons?
Im already doing a scan in the walkto function, every 10th loop

Besides that, to minimize the mapobject calls I decided to store the results for a while

When I stored the result(s) in a global var, and later on print then out again, i only see 3 empty cells for some reason. Just to be clear, I did not do another request.
When I start the bot, check map objects and stored them globally
Use the global results to filter forts and go there one by one
when arrived I use the same globals to filter pokemons. guess what, its empty?!!

Finding all Pokemon in cells

Hello,

first of all: thank you for that amazing project!

I currently struggle with finding all the pokemon around my location.

I set my location:
session.setCoordinates(lat, lng)

Then I call:
cells = session.getMapObjects(radius = 4)

After that I loop through the cells with:

for cell in cells.map_cells:
     pokemons = [p for p in cell.wild_pokemons] + [p for p in cell.catchable_pokemons]
     for pokemon in pokemons:
.....

But I only find very few pokemon (I scanned already a big area). Did anything change with the update tonight? I just finished this script yesterday evening, so I can't tell you if I would have found more pokemon in the last days.

I dont want to catch any of them. I only want to create a Database for myself to get the spawn points and spawn times of certain pokemon.

Thanks in advance!

Geo Lookups Failing

For the past few hours all geo lookup requests have been failing with the following error regardless of location inputted, long / lat, etc:

Line 102,api.py - 2016-07-24 17:35:21,338 - INFO - Creating PTC session for USER
Line 788,connectionpool.py - 2016-07-24 17:35:21,343 - INFO - Starting new HTTPS connection (1): sso.pokemon.com
Traceback (most recent call last):
  File "/home/user/pokemongo-api/pogo/demo.py", line 265, in <module>
    session = poko_session.authenticate(args.location)
  File "/home/user/pokemongo-api/pogo/api.py", line 143, in authenticate
    }[self.provider](locationLookup=locationLookup)
  File "/home/user/pokemongo-api/pogo/api.py", line 135, in createPTCSession
    session=session
  File "/home/user/pokemongo-api/pogo/api.py", line 61, in createPogoSession
    location = Location(locationLookup, self.geo_key)
  File "/home/user/pokemongo-api/pogo/location.py", line 15, in __init__
    self.latitude, self.longitude, self.altitude = self.setLocation(locationLookup)
  File "/home/user/pokemongo-api/pogo/location.py", line 49, in setLocation
    raise GeneralPogoException('Error in Geo Request')
custom_exceptions.GeneralPogoException: Error in Geo Request

Anyone able to make successful requests right now?

TypeError: __init__() got an unexpected keyword argument 'syntax'

I have all the current dependencies at the exact versions in requirements.txt. I get the following error Python 2.7 Debian. It doesn't matter the arguments given.

pokemongo-api/pogo$ ./demo.py
Traceback (most recent call last):
  File "./demo.py", line 8, in <module>
    from api import PokeAuthSession
  File "~/pokemongo-api/pogo/api.py", line 7, in <module>
    from session import PogoSession
  File "~/pokemongo-api/pogo/session.py", line 2, in <module>
    from POGOProtos.Networking.Requests import Request_pb2
  File "~/pokemongo-api/pogo/POGOProtos/Networking/Requests/Request_pb2.py", line 16, in <module>
    from POGOProtos.Networking.Requests import RequestType_pb2 as POGOProtos_dot_Networking_dot_Requests_dot_RequestType__pb2
  File "~/pokemongo-api/pogo/POGOProtos/Networking/Requests/RequestType_pb2.py", line 23, in <module>
    POKEMON\x10\x94\x01\x12\x15\n\x10NICKNAME_POKEMON\x10\x95\x01\x12\x10\n\x0b\x45QUIP_BADGE\x10\x96\x01\x12\x19\n\x14SET_CONTACT_SETTINGS\x10\x97\x01\x12\x15\n\x10GET_ASSET_DIGEST\x10\xac\x02\x12\x16\n\x11GET_DOWNLOAD_URLS\x10\xad\x02\x12\x1c\n\x17GET_SUGGESTED_CODENAMES\x10\x91\x03\x12\x1d\n\x18\x43HECK_CODENAME_AVAILABLE\x10\x92\x03\x12\x13\n\x0e\x43LAIM_CODENAME\x10\x93\x03\x12\x0f\n\nSET_AVATAR\x10\x94\x03\x12\x14\n\x0fSET_PLAYER_TEAM\x10\x95\x03\x12\x1b\n\x16MARK_TUTORIAL_COMPLETE\x10\x96\x03\x12\x16\n\x11LOAD_SPAWN_POINTS\x10\xf4\x03\x12\t\n\x04\x45\x43HO\x10\x9a\x05\x12\x1b\n\x16\x44\x45\x42UG_UPDATE_INVENTORY\x10\xbc\x05\x12\x18\n\x13\x44\x45\x42UG_DELETE_PLAYER\x10\xbd\x05\x12\x17\n\x12SFIDA_REGISTRATION\x10\xa0\x06\x12\x15\n\x10SFIDA_ACTION_LOG\x10\xa1\x06\x12\x18\n\x13SFIDA_CERTIFICATION\x10\xa2\x06\x12\x11\n\x0cSFIDA_UPDATE\x10\xa3\x06\x12\x11\n\x0cSFIDA_ACTION\x10\xa4\x06\x12\x11\n\x0cSFIDA_DOWSER\x10\xa5\x06\x12\x12\n\rSFIDA_CAPTURE\x10\xa6\x06\x62\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'

Nice codebase

Will be watching this! Like your OO approach. Your accepting PR's? On IRC?

Pokemon type

Hi,
Is it possible to add the pokemon type in monsters objects ? (normal, fire, water ...)

Exception raised: 'MapPokemon' object has no attribute 'pokemon_data'

Whenever the Bot catches a Pokemon i get this Exception which causes reauthentification.
This only happens since today. Niantic must have changed something with their servers or somethin. Tried to track down the issue by looking at the code but couldnt figure it out.

Line 68,demo.py - 2016-08-01 20:50:40,519 - INFO - ZUBAT, 53.002505 meters away Line 391,demo.py - 2016-08-01 20:50:40,521 - CRITICAL - Exception raised: 'MapPokemon' object has no attribute 'pokemon_data' Line 83,api.py - 2016-08-01 20:50:40,522 - INFO - Creating Google session for XXXXXXXX Line 788,connectionpool.py - 2016-08-01 20:50:40,531 - INFO - Starting new HTTPS connection (1): android.clients.google.com Line 788,connectionpool.py - 2016-08-01 20:50:41,406 - INFO - Starting new HTTPS connection (1): android.clients.google.com

Anyone had any success with this?

Proper renew API URL ?

Is it possible to renew the API URL properly ?
On error 53, you get a new API_URL in the response

Reduce frequency of GetMapObjects calls

Aren't we suppose to wait 5 seconds now (with the new changes) between two GetMapObjects calls?
Ideally the bot would use the values sent by the server to cope with further changes in that regard.

Line 525,session.py - 2016-08-02 08:14:51,945 - INFO - Walking 316.470710 meters. This will take 98.897097 seconds...
Line 147,session.py - 2016-08-02 08:15:14,238 - ERROR - ('Connection aborted.', error(104, 'Connection reset by peer'))
Line 443,demo.py - 2016-08-02 08:15:14,243 - CRITICAL - GeneralPogoException raised: Probably server fires.

[refactoring] change check... methods to properties

As above. Methods from class Session have checks that only returns local cached response. Name check indicates for checking, not returning something.

Can we change it to properties? It might look like this

`
session.eggs

session.inventory

session.badges

session.download_settings
`

getProfile doesn't include all data from protos

First off, thank you very much for the API. I am using it in one of my projects and it's fantastic. I've come to a point in my project where I'd like to query the server for player stats and I've hit a roadblock. I've looked at the protos and it seems like the PlayerData_Pb2 does not contain the /data/player/playerstats_pb2 proto, and I am not familiar enough with ProtoBuf to fix it. I'm hoping that you might be able to offer some insight. Thanks again!

[Help Required] How to get Move Names?

Hi, firstly thanks for the API, it's really useful.

I'm having some problems referencing the Move Names, though. I am using:

`party = session.checkInventory().party
myParty = []

# Get the party and put it into a nicer list
for pokemon in party:
    IvPercent = ((pokemon.individual_attack + pokemon.individual_defense + pokemon.individual_stamina)*100)/45
    L = [pokedex[pokemon.pokemon_id],pokemon.cp,pokemon.individual_attack,pokemon.individual_defense,pokemon.individual_stamina,IvPercent,pokemon.move_1,pokemon.move_2]`

Everything works okay, except for the move_1and move_2. These show up as numbers instead of the names of the moves. I've tried digging through the code, but I cannot figure out how the session.checkInventory().party gets the Move names.

Any help would be very much appreciated.

Using refresh tokens for google login

I've tried to make heads or tails of the google authorization with little success. I was hoping it would be possible to access a google account using a refresh token provided by google, similar to what PokéAdvisor does. This could provide access without providing the e-mails account username and password. I've personally have had issues because my google account isn't @gmail.com and can't be authorized via the normal google login API.

The token is provided from this url

The java api use this method. I don't have the knowledge to get this working.

Got an error on first running demo, any idea?

Line 105,api.py - 2016-07-31 00:23:28,953 - INFO - Creating PTC session for zyy20853
Line 788,connectionpool.py - 2016-07-31 00:23:28,965 - INFO - Starting new HTTPS connection (1): sso.pokemon.com
Line 64,api.py - 2016-07-31 00:23:30,261 - INFO - Coordinates: 47.377938 8.5401898 0.0
Traceback (most recent call last):
File "demo.py", line 385, in
session = poko_session.authenticate(locationLookup=args.location)
File "/Users/MD103/Desktop/pokemon/pokemongo-api/pogo/api.py", line 148, in authenticate
}[self.provider](locationLookup=locationLookup, noop=noop)
File "/Users/MD103/Desktop/pokemon/pokemongo-api/pogo/api.py", line 139, in createPTCSession
noop=noop
File "/Users/MD103/Desktop/pokemon/pokemongo-api/pogo/api.py", line 71, in createPogoSession
location
File "/Users/MD103/Desktop/pokemon/pokemongo-api/pogo/session.py", line 57, in init
self.createApiEndpoint(),
File "/Users/MD103/Desktop/pokemon/pokemongo-api/pogo/session.py", line 85, in createApiEndpoint
req = self.wrapInRequest(payload)
File "/Users/MD103/Desktop/pokemon/pokemongo-api/pogo/session.py", line 116, in wrapInRequest
auth_info=info
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 522, in init
_ReraiseTypeErrorWithFieldName(message_descriptor.name, field_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 453, in _ReraiseTypeErrorWithFieldName
six.reraise(type(exc), exc, sys.exc_info()[2])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 520, in init
copy.MergeFrom(new_val)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 1237, in MergeFrom
"expected %s got %s." % (cls.name, type(msg).name))
TypeError: Parameter to MergeFrom() must be instance of same class: expected AuthTicket got NoneType. for field RequestEnvelope.auth_ticket

Bug in findClosestPokemon in demo.py

I think there is a small bug in demo.py findClosestPokemon. If dist < closest, you update pokemonBest, but not closest, which means pokemonBest will be the last pokemon in the list, rather than the nearest.

Error when I try to getMapObjects with radius >50

Hey,
When i run the script with a radius<50 I get 0 pokémon...:

Line 40,demo.py - 2016-08-08 23:05:31,875 - INFO - Finding Nearby Pokemon:
Line 46,demo.py - 2016-08-08 23:05:32,174 - INFO - Current pos: 48.579415, 7.740
778
Line 195,demo.py - 2016-08-08 23:05:32,174 - INFO - Finding Nearest Fort:
Line 173,demo.py - 2016-08-08 23:05:32,176 - INFO - Sorting Nearest Forts:
Line 199,demo.py - 2016-08-08 23:05:32,480 - INFO - No forts found..

But when I put a radius >50, I get this error:

Line 40,demo.py - 2016-08-08 23:11:56,565 - INFO - Finding Nearby Pokemon:
Line 224,session_bare.py - 2016-08-08 23:11:56,694 - ERROR - status_code: 3
request_id: 117650377702
unknown6 {
response_type: 6
unknown2 {
unknown1: 1
}
}
returns: ""

Traceback (most recent call last):
File "pogo\demo.py", line 408, in <
module>
pokemon = findBestPokemon(session)
File "pogo\demo.py", line 41, in fi
ndBestPokemon
cells = session.getMapObjects()
File "pogo\session.py", line 100, i
n getMapObjects
res = self.wrapAndRequest(payload)
File "pogo\session_bare.py", line 1
83, in wrapAndRequest
self.parseDefault(res)
File "pogo\session_bare.py", line 2
25, in parseDefault
raise PogoResponseException("Expected response not returned")
custom_exceptions.PogoResponseException: Expected response not returned

Anyone knows why it occures?

ERROR - list index out of range: pokemongo-api/pogo/session.py", line 193, in parseDefault

Hi all,
about every other time i run a call to catch pokemon, or get profile, I get the following:

Line 40,demo.py - 2016-07-29 14:12:35,856 - INFO - Finding Nearby Pokemon: Line 198,session.py - 2016-07-29 14:12:35,907 - ERROR - list index out of range Traceback (most recent call last): File "/Users/blarg/Documents/pokemongo-api/pogo/session.py", line 193, in parseDefault self._state.eggs.ParseFromString(res.returns[1]) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/google/protobuf/internal/containers.py", line 204, in __getitem__ return self._values[key] IndexError: list index out of range

Once i get the error, if I run the exact same command again, it works. Thoughts?

Lots of request issue's

Besides all the sleep delays I put in,
I'm receiving a lot of
ERROR - Exception raised: 'ascii' codec can't encode character u'\xf1' in position 24: ordinal not in range(128)
When I'm about to moving to or encounter a pokemon, trying to figure this out.
Anyone else seen this before and know how to fix it?

[Update] Added missing pokemon families

Just a quick and dirty update to Enums/PokemonFamilyId_pb2

Main fix for which candy type to use for the 2nd evolution which has a 3rd.

_descriptor.EnumValueDescriptor(
      name='FAMILY_PIDGEOTTO', index=81, number=16,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_CHARMELEON', index=82, number=4,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_WARTORTLE', index=83, number=7,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_METAPOD', index=84, number=10,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_KAKUNA', index=85, number=13,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_NIDORINA', index=86, number=29,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_NIDORINO', index=87, number=32,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_POLIWHIRL', index=88, number=60,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_KADABRA', index=89, number=63,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_MACHOKE', index=90, number=66,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_WEEPINBELL', index=91, number=69,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_GRAVELER', index=92, number=74,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_MAGNETON', index=93, number=81,
      options=None,
      type=None),
    _descriptor.EnumValueDescriptor(
      name='FAMILY_HAUNTER', index=94, number=92,
      options=None,
      type=None),

I'm not quite known with github, and the Pull Requests...

If anyone finds its usefull, please use it :)
Maybe better to set it up in the pokedex, so when there is a proto update which don't include this.. yet at least, then it will be lost again

Issue with finding all Pokemon in cells

Hello,

first of all: thank you for that amazing project!

I currently struggle with finding all the pokemon around my location.

I set my location:
session.setCoordinates(lat, lng)

Then I call:
cells = session.getMapObjects(radius = 4)

After that I loop through the cells with:

for cell in cells.map_cells:
     pokemons = [p for p in cell.wild_pokemons] + [p for p in cell.catchable_pokemons]
     for pokemon in pokemons:
.....

But I only find very few pokemon (I scanned already a big area). Did anything change with the update tonight? I just finished this script yesterday evening, so I can't tell you if I would have found more pokemon in the last days.

I dont want to catch any of them. I only want to create a Database for myself to get the spawn points and spawn times of certain pokemon.

Thanks in advance!

edit: sorry for posting two issues... I just tried to edit the top line....

Hatch egg?

I had to log on to my device to have the egg hatch in the incubator. Anyone know of an app call to hatch it once it reaches the distance?

Python 3 TypeError: object.__init__() takes no parameters

Traceback (most recent call last):
  File "pogo/demo.py", line 8, in <module>
    from api import PokeAuthSession
  File "pokemongo-api/pogo/api.py", line 7, in <module>
    from session import PogoSession
  File "pokemongo-api/pogo/session.py", line 23, in <module>
    from inventory import Inventory, items
  File "pokemongo-api/pogo/inventory.py", line 1, in <module>
    from pokedex import pokedex
  File "pokemongo-api/pogo/pokedex.py", line 272, in <module>
    pokedex = Pokedex()
  File "pokemongo-api/pogo/pokedex.py", line 164, in __init__
    super(dict, self).__init__(self)
TypeError: object.__init__() takes no parameters

We can change

super(dict, self).__init__(self)

to

super(dict, self).__init__()

in:

  • pogo/inventory.py
  • pogo/pokedex.py

It work as expected in python 2.7 and python 3.5

Master: session.py - typo

On line 358:
spawn_point_id=pokemon.spawn_point_id

does not work, should be spawn_point_guid=pokemon.spawn_point_id

First time login

Are there any way to deal with the first login settings programatically?
I mean, select skin color, clothes, name, and check that first agreement

If I create a new account, the bot doesn't see any pokestop or catchable pokemon until I go manually throught this first settings

Probably this is not on the roadmap of the API if someone can give me a tip about how to decript the packages and figure by myself the protocol I would be very glad

Correctly calling catchPokemon

Hello, I am having problems with trying to execute session.catchPokemon(130, 1)
where I get TabError: inconsistent use of tabs and spaces in indentation

fortDetails returns status_code 52

Hi I wonder what status_code 52 is.
The parser will fail, so I started to put in a check in the session class.

def getFortDetails(self, fort):
        # Create request
        payload = [Request_pb2.Request(
            request_type=RequestType_pb2.FORT_DETAILS,
            request_message=FortDetailsMessage_pb2.FortDetailsMessage(
                fort_id=fort.id,
                latitude=fort.latitude,
                longitude=fort.longitude,
            ).SerializeToString()
        )]
        # Send
        res = self.wrapAndRequest(payload)
        # Parse
        if res.status_code:
            if res.status_code == 52:
                return None
        self._state.fortDetails.ParseFromString(res.returns[0])

        # Return everything
        return self._state.fortDetails

Then I received parser issues with getmap objects, started printing the res before parsing, and its not showing me the error anymore...

Will keep running like it is now, to see if i receive more info about this.

biggest problem is, the script will crash out and wont go on...


Yep same status code for mapobjects.
made the same check, also inside the demo after getting cells in sortCloseForts and findBestPokemon
if cells is None:
return None

errors while using items

For using Raspberries or Catching pokemons I'm finding a lot of issues
responses with status_code 3 etc
even with a delay of 10 seconds, i still get this status_code

Cannot access fort pokemon

Hi there,

Can't seem to get access to Fort Pokemon from PokeStops. What is the correct variables for the encounter message, I have tried: Fort.id & fort.lure_info.encounter_id without sucess.

Cheers

No non-repeatable submessage field "pokemon_family"

I'm getting this message when running demo.py:

Traceback (most recent call last):
  File "demo.py", line 385, in <module>
    session = poko_session.authenticate(locationLookup=args.location)
  File "/home/legopelle/webdev/python/gym-rankings-backend/pogo/api.py", line 148, in authenticate
    }[self.provider](locationLookup=locationLookup, noop=noop)
  File "/home/legopelle/webdev/python/gym-rankings-backend/pogo/api.py", line 139, in createPTCSession
    noop=noop
  File "/home/legopelle/webdev/python/gym-rankings-backend/pogo/api.py", line 71, in createPogoSession
    location
  File "/home/legopelle/webdev/python/gym-rankings-backend/pogo/session.py", line 62, in __init__
    self.getInventory()
  File "/home/legopelle/webdev/python/gym-rankings-backend/pogo/session.py", line 216, in getInventory
    self.getProfile()
  File "/home/legopelle/webdev/python/gym-rankings-backend/pogo/session.py", line 249, in getProfile
    res = self.wrapAndRequest(payload)
  File "/home/legopelle/webdev/python/gym-rankings-backend/pogo/session.py", line 153, in wrapAndRequest
    self.parseDefault(res)
  File "/home/legopelle/webdev/python/gym-rankings-backend/pogo/session.py", line 207, in parseDefault
    self.inventory = Inventory(item)
  File "/home/legopelle/webdev/python/gym-rankings-backend/pogo/inventory.py", line 76, in __init__
    if data.HasField("pokemon_family"):
  File "/usr/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 835, in HasField
    raise ValueError(error_msg % field_name)
ValueError: Protocol message has no non-repeated submessage field "pokemon_family"

Is there some setup step I have missed?

Get ID's from names

Hi all,

i would like to get the ID's using names (pokemon and items)
That will make it a bit easier to put some config settings.

Like a argument, ignorepokemon ["pidgey","rattata"] etc.

But I'll need to get the ID from that string name.

Can we do that without making a new dictionary?

TypeError: __init__() got an unexpected keyword argument 'syntax'

The error appeared after updating to version 0.31.0

~/pokemongo-api-master/pogo$ python demo.py -a "google" -u "[email protected]" -p "thepassword" -l "The Atlantic Ocean"
Traceback (most recent call last):
File "demo.py", line 8, in
from api import PokeAuthSession
File "/home/vitaliy/pokemongo-api-master/pogo/api.py", line 7, in
from session import PogoSession
File "/home/vitaliy/pokemongo-api-master/pogo/session.py", line 2, in
from POGOProtos.Networking.Requests import Request_pb2
File "/home/vitaliy/pokemongo-api-master/pogo/POGOProtos/Networking/Requests/Request_pb2.py", line 16, in
from POGOProtos.Networking.Requests import RequestType_pb2 as POGOProtos_dot_Networking_dot_Requests_dot_RequestType__pb2
File "/home/vitaliy/pokemongo-api-master/pogo/POGOProtos/Networking/Requests/RequestType_pb2.py", line 23, in
POKEMON\x10\x94\x01\x12\x15\n\x10NICKNAME_POKEMON\x10\x95\x01\x12\x10\n\x0b\x45QUIP_BADGE\x10\x96\x01\x12\x19\n\x14SET_CONTACT_SETTINGS\x10\x97\x01\x12\x15\n\x10GET_ASSET_DIGEST\x10\xac\x02\x12\x16\n\x11GET_DOWNLOAD_URLS\x10\xad\x02\x12\x1c\n\x17GET_SUGGESTED_CODENAMES\x10\x91\x03\x12\x1d\n\x18\x43HECK_CODENAME_AVAILABLE\x10\x92\x03\x12\x13\n\x0e\x43LAIM_CODENAME\x10\x93\x03\x12\x0f\n\nSET_AVATAR\x10\x94\x03\x12\x14\n\x0fSET_PLAYER_TEAM\x10\x95\x03\x12\x1b\n\x16MARK_TUTORIAL_COMPLETE\x10\x96\x03\x12\x16\n\x11LOAD_SPAWN_POINTS\x10\xf4\x03\x12\t\n\x04\x45\x43HO\x10\x9a\x05\x12\x1b\n\x16\x44\x45\x42UG_UPDATE_INVENTORY\x10\xbc\x05\x12\x18\n\x13\x44\x45\x42UG_DELETE_PLAYER\x10\xbd\x05\x12\x17\n\x12SFIDA_REGISTRATION\x10\xa0\x06\x12\x15\n\x10SFIDA_ACTION_LOG\x10\xa1\x06\x12\x18\n\x13SFIDA_CERTIFICATION\x10\xa2\x06\x12\x11\n\x0cSFIDA_UPDATE\x10\xa3\x06\x12\x11\n\x0cSFIDA_ACTION\x10\xa4\x06\x12\x11\n\x0cSFIDA_DOWSER\x10\xa5\x06\x12\x12\n\rSFIDA_CAPTURE\x10\xa6\x06\x62\x06proto3')
TypeError: init() got an unexpected keyword argument 'syntax'

Exception 17 during mass evolve

I rewrote a little part of the evolveAll function

def evolveAllPokemon(session):
    for pokemon in curInventory.party:
        currentID = pokemon.pokemon_id
        currentPokemon = pokedex[currentID]

        candies = session.checkInventory().candies[currentID]
        requiredCandies = pokedex.evolves[currentID]

        if requiredCandies > 0:
            if candies > requiredCandies:
                evolveResult = session.evolvePokemon(pokemon)
                time.sleep(1.5)
                if evolveResult.result == 1:
                    print("Evolved...")
        time.sleep(1)

I already found out, that when I started using defined vars currentID, currentPokemon, requiredCandies, that the loop will last longer.
The sleep function did not make any difference

I can go up till 6, and then I get the exception.

Anyone has any idea why? And how to solve it?
It doesn't seem to be such a big deal tho.

Is it something with CPU? RAM?

I do find the process really intensive, as my macbook's fans are running on max speed and cpu is still reaching 80 degrees Celcius :-D

getMapObjects default radius too high

The getMapObject Radius is now set to 1000 by default.
With such high radius I get:
{'responses': {'ENCOUNTER': {'status': 6}}, 'request_id': 123167996238794584, 'status_code': 1, 'unknown6': [{'unknown2': {'unknown1': 1}, 'response_type': 6}]}

No Check for Full Pokemon Inventory

It seems like there is no check for whether a trainer is at their max number of pokemon. I encountered this problem, and trainer.encounterAndCatch was unable to determine a "bestBall" or "altBall." The encounter itself clearly states that the trainer's pokemon list is full, but the program throws the, "out of usable balls," exception.

Malformed response

Something must have changed in the API as today this started to happen only when trying to catch a pokemon. Everything else seems to be ok.


Line 80,demo.py - 2016-07-24 10:33:25,047 - INFO - Catching RHYHORN:
Line 473,session.py - 2016-07-24 10:33:25,047 - INFO - Walking 25.147343 meters. This will take 7.858545 seconds...
Line 193,session.py - 2016-07-24 10:33:34,880 - ERROR - list index out of range
Traceback (most recent call last):
  File "demo.py", line 251, in 
    walkAndCatch(session, pokemon)
  File "demo.py", line 82, in walkAndCatch
    logging.info(session.encounterAndCatch(pokemon))
  File "/Users/eep/Work/Pokemon/pokemongo-api/pogo/session.py", line 496, in encounterAndCatch
    return self.catchPokemon(pokemon, pokeball)
  File "/Users/eep/Work/Pokemon/pokemongo-api/pogo/session.py", line 362, in catchPokemon
    res = self.wrapAndRequest(payload)
  File "/Users/eep/Work/Pokemon/pokemongo-api/pogo/session.py", line 144, in wrapAndRequest
    self.parseDefault(res)
  File "/Users/eep/Work/Pokemon/pokemongo-api/pogo/session.py", line 194, in parseDefault
    raise GeneralPogoException("Error parsing response. Malformed response")
custom_exceptions.GeneralPogoException: Error parsing response. Malformed response

New Error: list index out of range

First, thanks a lot for the clean abstraction and nice code. It was working perfectly up to a point where i started getting

Traceback (most recent call last):
  File "demo.py", line 65, in <module>
    logging.info(session.encounterAndCatch(pokemonBest))
  File "/Users/ahmadassaf/Downloads/Applications/pokemongo-api/pogo/session.py", line 323, in encounterAndCatch
    return self.catchPokemon(pokemon, pokeball)
  File "/Users/ahmadassaf/Downloads/Applications/pokemongo-api/pogo/session.py", line 312, in catchPokemon
    res = self.wrapAndRequest(payload)
  File "/Users/ahmadassaf/Downloads/Applications/pokemongo-api/pogo/session.py", line 129, in wrapAndRequest
    if(defaults): self.parseDefault(res)
  File "/Users/ahmadassaf/Downloads/Applications/pokemongo-api/pogo/session.py", line 174, in parseDefault
    self.state.settings.ParseFromString(res.returns[4])
  File "/usr/local/lib/python2.7/site-packages/google/protobuf/internal/containers.py", line 204, in __getitem__
    return self._values[key]
IndexError: list index out of range

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.