Code Monkey home page Code Monkey logo

pokegoapi-java's Introduction

PokeGOAPI-Java

Pokemon GO Java API

Build Status Code Quality: Java Total Alerts

Javadocs : CLICK ME


❗ ❗ ❗

This API may have issues when the PokemonGO servers are under high load or down, in this case please wait for the official to get back up. You can check the official servers status on IsPokemonGoDownOrNot.com or MMOServerStatus.com.

This API doesnt fake the official client perfectly, niantic may know that you aren't using the official app, we encourage you to use an alternate account to play with this API.

If you are using this lib to catch pokemon and loot pokestop, take care that you aren't teleporting, the servers may issue a softban against your client (its temporary, between 10 and 30 minutes in general).

❗ ❗ ❗


How to import

allprojects {
  repositories {
      jcenter()
  }
}

dependencies {
  compile 'com.pokegoapi:PokeGOAPI-library:0.X.X'
}

Replace X.X with the version below: Download

OR

Import JAR with gradle

  • Complete Build from source below
  • Open the project gradle.build file
  • Locate dependencies {
  • Add compile fileTree(include: ['PokeGOAPI-library-all-*.jar'], dir: 'PATH_TO/PokeGOAPI-Java/library/build/libs')
    • (PATH_TO is the exact path from root to the API folder, i.e. C:/MyGitProjects)
    • (Make sure to perform a clean build to avoid multiple versions being included)

OR

Import JAR in Eclipse

  • Complete Build from source below
  • Right click on the project
  • Select Build path > Java Build Path
  • Select Libraries tab
  • Select Add External JARs…
  • Select PokeGOAPI-Java/library/build/libs/PokeGOAPI-library-all-0.X.X.jar
    • (0.X.X refers to the version number provided in the JAR filename, ie. 0.3.0)
  • Finish

Build from source

  • Clone the repo and cd into the folder
  • git submodule update --init
  • ./gradlew :library:build
  • you should have the api jar in library/build/libs/PokeGOAPI-library-all-0.X.X.jar
    • (0.X.X refers to the version number provided in the JAR filename, ie. 0.3.0)

PS : for users who want to import the api into Eclipse IDE, you'll need to :

  • build once : ./gradlew :library:build
  • Right click on the project
  • Select Build path > Configure Build Path > Source > Add Folder
  • Select library/build/generated/source/proto/main/java
  • Finish

Usage example (mostly how to login) :

OkHttpClient httpClient = new OkHttpClient();

/** 
* Google: 
* You will need to redirect your user to GoogleUserCredentialProvider.LOGIN_URL
* Afer this, the user must signin on google and get the token that will be show to him.
* This token will need to be put as argument to login.
*/
GoogleUserCredentialProvider provider = new GoogleUserCredentialProvider(httpClient);

// in this url, you will get a code for the google account that is logged
System.out.println("Please go to " + GoogleUserCredentialProvider.LOGIN_URL);
System.out.println("Enter authorization code:");
			
// Ask the user to enter it in the standard input
Scanner sc = new Scanner(System.in);
String access = sc.nextLine();
			
// we should be able to login with this token
provider.login(access);
PokemonGo go = new PokemonGo(httpClient);
go.login(provider);

/**
* After this, if you do not want to re-authorize the google account every time, 
* you will need to store the refresh_token that you can get the first time with provider.getRefreshToken()
* ! The API does not store the refresh token for you !
* log in using the refresh token like this :
* - Needs hasher - example below
*/
PokemonGo go = new PokemonGo(httpClient);
go.login(new GoogleUserCredentialProvider(httpClient, refreshToken), hasher);

/**
* PTC is much simpler, but less secure.
* You will need the username and password for each user log in
* This account does not currently support a refresh_token. 
* Example log in :
* - Needs hasher - example below
*/
PokemonGo go = new PokemonGo(httpClient);
go.login(new PtcCredentialProvider(httpClient, username, password), hasher);

// After this you can access the api from the PokemonGo instance :
go.getPlayerProfile(); // to get the user profile
go.getInventories(); // to get all his inventories (Pokemon, backpack, egg, incubator)
go.setLocation(lat, long, alt); // set your position to get stuff around (altitude is not needed, you can use 1 for example)
go.getMap().getCatchablePokemon(); // get all currently Catchable Pokemon around you

// If you want to go deeper, you can directly send your request with our RequestHandler
// For example, here we are sending a request to get the award for our level
// This applies to any method defined in the protos file as Request/Response)

LevelUpRewardsMessage msg = LevelUpRewardsMessage.newBuilder().setLevel(yourLVL).build(); 
ServerRequest serverRequest = new ServerRequest(RequestType.LEVEL_UP_REWARDS, msg);
go.getRequestHandler().sendServerRequests(serverRequest);

// and get the response like this :

LevelUpRewardsResponse response = null;
try {
	response = LevelUpRewardsResponse.parseFrom(serverRequest.getData());
} catch (InvalidProtocolBufferException e) {
	// its possible that the parsing fail when servers are in high load for example.
	throw new RemoteServerException(e);
}

public static HashProvider getHashProvider(){
    String POKEHASH_KEY = "****************";
    if(POKEHASH_KEY != null && POKEHASH_KEY.length() > 0){
        return new PokeHashProvider(PokeHashKey.from(POKEHASH_KEY), true);
    }
    throw new IllegalStateException("Cannot start example without hash key");
}

(Async)CatchOptions

Parameters for a capture now use a CatchOptions or AsyncCatchOptions object

This object allows setting all parameters at once, or modifying them on-the-fly

import com.pokegoapi.api.settings.AsyncCatchOptions;

OR

import com.pokegoapi.api.settings.CatchOptions;

Usage:

CatchOptions options = new CatchOptions(go);
options.maxRazzberries(5);
options.useBestBall(true);
options.noMasterBall(true);

cp.catchPokemon(options);

OR

AsyncCatchOptions options = new AsyncCatchOptions(go);
options.useRazzberries(true);
options.useBestBall(true);
options.noMasterBall(true);

cp.catchPokemon(options);

Each option has a default and the most relevant option will override others with similar functionality (for example, usePokeBall will set the minimum of useBestBall, a maximum by using it alone, or the specific value with noFallback). See the javadocs for more info.

##Android Dev FAQ

  • I can't use the sample code! It just throws a login exception!

You're running the sample code on the UI thread. Strict mode policy will throw an exception in that case and its being caught by the network client and treating it as a login failed exception. Run the sample code on a background thread in AsyncTask or RXJava and it will work.

  • I want to submit a refactor so that this library will use Google Volley

This library is meant to be a Java implementation of the API. Google Volley is specific to Android and should not be introduced in this library. However, if you still want to refactor it, you should create it as a separate project.

  • How can I use Android's native Google sign in with this library?

You can't. The Google Identity Platform uses the SHA1 fingerprint and package name to authenticate the caller of all sign in requests. This means that Niantic would need to add your app's SHA1 fingerprint and package name to their Google API Console. If you ever requested a Google Maps API key, you went through the same process. An alternative would be using a WebView to access the web based OAuth flow. This will work with the client ID and secret provided by this library.

Contributing

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Useful information about your new features'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request on the Development branch :D

Contributors

  • @Grover-c13
  • @jabbink
  • @Aphoh
  • @mjmfighter
  • @vmarchaud
  • @langerhans
  • @fabianterhorst
  • @LoungeKatt

You can join us in the slack channel #javaapi on the pkre.slack.com (you can get invited here)

pokegoapi-java's People

Contributors

abandonedcart avatar aphoh avatar aschlosser avatar bjornwater avatar cyperghost avatar enochen avatar fabianterhorst avatar furtif avatar gdespres avatar gegy avatar gionata-bisciari avatar grover-c13 avatar igio90 avatar jabbink avatar jacaru avatar jari27 avatar langerhans avatar mgorski-mg avatar michibat01 avatar mjmjelde avatar nateschickler0 avatar nyazuki avatar pvanassen avatar rajulbhatnagar avatar ramarro123 avatar s7092910 avatar sadye avatar sek-consulting avatar svarzee avatar vmarchaud 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  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

pokegoapi-java's Issues

MapObjectCells

Is there any specific setting for the map cells? I'm using http://s2map.com to get cell ids, but i always get a "missedCells" response with all my requested cells back. Or am i missing something?

java.lang.NoClassDefFoundError

I got this error when try to run the API in Android Studio:
java.lang.NoClassDefFoundError: okhttp3.internal.tls.OkHostnameVerifier
in the line
OkHttpClient httpClient = new OkHttpClient();

In my gradle i import the corrects dependencies:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.github.Grover-c13:PokeGOAPI-Java:master-SNAPSHOT'
}

And in my other gradle:

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

I spend like 4 hours finding a solution and came up with nothing, so i ask you for help.

Persisting Auth info

There is currently no way to persist auth info. This is useful for apps where a user will login and then use and exit the app, as the next time they open the app their auth info can be retrieved from disk instead of requiring them to log in again.

protocol buffer dependency

I added pokegoapi as a maven dependency using jitpack, but it wouldn't work until I explicitly added the protocol buffer dependency to my project as well.

Not sure how to fix it or I would do a PR

Wild Pokemons

I can get neaby gyms and pokestops but there is a issue with wild pokemons do you guys aware of that ?

com.pokegoapi.main.Request 404 Not found

Has you can read, someone deleted it, its gonna be easier if someone can re-push it again ;)
PS : gonna submit a PR to add how to build/install the api to the readme, might push it with it.

spawnPoints / decimatedSpawnPoints

Just for clarification:
I assume spawnpoints are the coordinates where it is possible that pokemons spawn, am i right? What's the difference between spawnPoints and decimatedSpawnPoints?

Error NoClassDefFound on Android

I'm trying to use these API on Android, I built the bundle, imported in the project and added compile files('libs/PokeGOAPI-Java_bundle-0.0.1-SNAPSHOT.jar') on gradle.build (I'm on Android studio).
I can correctly build my project and run it, but at runtime when I try to log in (both with PTC and Google) the app crashes.
Here's the log:

java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:309) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.NoClassDefFoundError: Failed resolution of: LPOGOProtos/Networking/EnvelopesOuterClass$Envelopes$RequestEnvelope$AuthInfo; at com.pokegoapi.auth.GoogleLogin.login(GoogleLogin.java:78) at com.acatch.pompomon.pokemon.MainActivity$Login.doInBackground(MainActivity.java:98) at com.acatch.pompomon.pokemon.MainActivity$Login.doInBackground(MainActivity.java:56) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)  at java.lang.Thread.run(Thread.java:818)  Caused by: java.lang.ClassNotFoundException: Didn't find class "POGOProtos.Networking.EnvelopesOuterClass$Envelopes$RequestEnvelope$AuthInfo" on path: DexPathList[[zip file "/data/app/com.acatch.pompomon.pokemon-2/base.apk"],nativeLibraryDirectories=[/data/app/com.acatch.pompomon.pokemon-2/lib/arm, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at com.pokegoapi.auth.GoogleLogin.login(GoogleLogin.java:78)  at com.acatch.pompomon.pokemon.MainActivity$Login.doInBackground(MainActivity.java:98)  at com.acatch.pompomon.pokemon.MainActivity$Login.doInBackground(MainActivity.java:56)  at android.os.AsyncTask$2.call(AsyncTask.java:295)  at java.util.concurrent.FutureTask.run(FutureTask.java:237)  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)  at java.lang.Thread.run(Thread.java:818)  Suppressed: java.lang.NoClassDefFoundError: POGOProtos.Networking.EnvelopesOuterClass$Envelopes$RequestEnvelope$AuthInfo at dalvik.system.DexFile.defineClassNative(Native Method) at dalvik.system.DexFile.defineClass(DexFile.java:226) at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219) at dalvik.system.DexPathList.findClass(DexPathList.java:338) at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54) ... 11 more Suppressed: java.lang.ClassNotFoundException: POGOProtos.Networking.EnvelopesOuterClass$Envelopes$RequestEnvelope$AuthInfo at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 10 more Caused by: java.lang.NoClassDefFoundError: > > Class not found using the boot class loader; no stack trace available

So it seems it cannot find anything of POGO library (at runtime, at build time everything is fine).
I'm not sure but searching around seems like it could something related to DeX: http://stackoverflow.com/questions/28283688/noclassdeffounderror-for-jar-library-at-runtime-in-android-studio but I don't know which modules are defined as Application (I guess there aren't).

So, any idea?
And keep up the good work, if I'll find some time I'll contribute too

Implementation in Android, "real case" use?

Hey,

is there someone already trying to get this working on Android Studio or on android in general? With an demo app maybe. Just for confirmation and may get attention to this a bit more.

item interaction

Hello,

how can i drop items on my bag?

this one seems the most probable

go.getBag().removeItem(X,1)

but it doesn't work as expected (i try to remove all pokeballs and leave 100)

compile error for new pull

the new CatchablePokemon.java have some issue that block compile.

[ant:checkstyle] [WARN] /Users/rama/Dropbox/test/PokeGOAPI-Java/src/main/java/com/pokegoapi/api/map/pokemon/CatchablePokemon.java:123: First sentence of Javadoc is incomplete (period is missing) or not present. [SummaryJavadoc]
[ant:checkstyle] [WARN] /Users/rama/Dropbox/test/PokeGOAPI-Java/src/main/java/com/pokegoapi/api/map/pokemon/CatchablePokemon.java:132: 'if' construct must use '{}'s. [NeedBraces]
[ant:checkstyle] [WARN] /Users/rama/Dropbox/test/PokeGOAPI-Java/src/main/java/com/pokegoapi/api/map/pokemon/CatchablePokemon.java:133: 'if' construct must use '{}'s. [NeedBraces]
[ant:checkstyle] [WARN] /Users/rama/Dropbox/test/PokeGOAPI-Java/src/main/java/com/pokegoapi/api/map/pokemon/CatchablePokemon.java:134: 'if' construct must use '{}'s. [NeedBraces]
:checkstyleMain FAILED
FAILURE: Build failed with an exception.

ProfileRequest: Wrong RPC ID

I was having trouble retrieving the profile data and only got it to work after changing Communication.Method.GET_PLAYER_PROFILE to Communication.Method.GET_PLAYER.

I also had to change the fields from required to optional in inventory.proto under PlayerStatsProto and recompile the .java files with protoc.

com.google.protobuf.InvalidProtocolBufferException: Contents of buffer are null

Yesterday my code worked like a charm..
Now its throwing this exception at me like crazy, maybe the developer of pokemonGo changed something that we need to adapt to?

com.pokegoapi.exceptions.RemoteServerException: com.google.protobuf.InvalidProtocolBufferException: Contents of buffer are null
at com.pokegoapi.api.map.Map.getMapObjects(Map.java:171)
at com.pokegoapi.api.map.Map.getMapObjects(Map.java:143)
at com.pokegoapi.api.map.Map.getMapObjects(Map.java:89)
at com.pokegoapi.api.map.Map.getMapObjects(Map.java:79)
at com.pokegoapi.api.map.Map.getRetainedMapObject(Map.java:50)
at com.pokegoapi.api.map.Map.getCatchablePokemon(Map.java:63)
at de.busybeever.pokemongo.pokemonfinder.PokemonFinder$1.run(PokemonFinder.java:44)
at java.lang.Thread.run(Unknown Source)
//This is my line 44 in PokemonFinder
List li = pokemonGo.getMap().getCatchablePokemon();

Getting the amount of candy of a PkMn ID

Are you planning on implementing this, or is it there and I'm missing it?

It would be very useful as in validating wether a Pokémon can evolve or not before requesting it to the server and to calculate the optimum amount of Pokémon to transfer (and then transfer them).

And congrats on the work so far!

checkpoint checkin

Hello,

i am having trouble on understanding how i can checkin on a particular checkpoint that i found on map.

can someone point me on the right direction?

Also, there is a place with docs, like a wiki or such?

JavaDocs

Need to add JavaDoc annotations/commets for all public exposed methods (and preferably all methods :P),
and host them somewhere.

Pokestops should support the Active Pokemon Attribute

Intro
The game offers a feature where you can buff a pokestop to lure pokemons. After you used a Module (the item which boosts a pokestop) Pokemons will show up on a regular. Modules are active for 30 minutes.

Tech
After you used a Module on a pokestop the pokestop will get a ActivePokemon Value. See a example below.

 {  
                    "fortId":"47b4a55ad8c54454940396aaf0601e02.16",
                     "lastModifiedMs":"1469000053563",
                     "latitude":45.030225,
                     "longitude":-93.318969,
                     "enabled":true,
                     "fortType":1,
                     "activePokemon":{  
                        "spawnpointId":"47b4a55ad8c54454940396aaf0601e02.16",
                        "encounterId":"2142514281",
                        "pokedexTypeId":"V0021_POKEMON_SPEAROW",
                        "expirationTimeMs":"1469001133514"
                     }
                  },
                  {  
                     "fortId":"5ec40620884740d98d6969e372156c5c.16",
                     "lastModifiedMs":"1468999658570",
                     "latitude":45.029967,
                     "longitude":-93.319217,
                     "enabled":true,
                     "fortType":1,
                     "activePokemon":{  
                        "spawnpointId":"5ec40620884740d98d6969e372156c5c.16",
                        "encounterId":"1178527421",
                        "pokedexTypeId":"V0013_POKEMON_WEEDLE",
                        "expirationTimeMs":"1469001098512"
                     }
                  },

this is something i found in the protobuf files

message PokemonFortProto {
    string FortId = 1;
    int64 LastModifiedMs = 2;
    double Latitude = 3;
    double Longitude = 4;
    int32 Team = 5;
    int32 GuardPokemonId = 6;
    int32 GuardPokemonLevel = 7;
    bool Enabled = 8;
    ENUM.Holoholo.Rpc.FortType FortType = 9;
    int64 GymPoints = 10;
    bool IsInBattle = 11;
    //unknown ActiveFortModifier = 12;
    Holoholo.Rpc.MapPokemonProto ActivePokemon = 13;
    int64 CooldownCompleteMs = 14;
    ENUM.Holoholo.Rpc.Sponsor.Types.FortSponsor.Sponsor Sponsor = 15;
    ENUM.Holoholo.Rpc.RenderingType.Types.FortRenderingType.RenderingType RenderingType = 16;
 }

CatchablePokemons isn't working for me.

For some reason the size of CatchablePokemons is 0.

Collection<MapPokemonOuterClass.MapPokemon> catchablePokemons = this.api.getMap()
                    .getMapObjects(51.86177, 4.526361)
                    .getCatchablePokemons();

It worked fine before, but since I updated the API it's always an empty collection.

If I login on my phone, there are pokemon near that coordinate.

Imitate official app behaviour

The official app often does requests like this

+ GetHatchedEggs, GetInventory, CheckAwardedBadges, DownloadSettings

Should we replicate this in the API or should be let users of the API do this per application?

Also, the official app requests map objects every 1-5(? correct number is in the reply of DownloadSettings afaik) seconds, replicate this in the API or let others figure this out?

getFortDetails

Hello,

why getFortDetails get 2 long as params, and then cast to double?

shouldn't be 2 double?

No Readme or example

Hello,
could you please provide some example how to run your API? Im happy that someone is developing JAVA code for the API and I wont need to use python which Im unable to make working for missing libs. But it would be good to have some README or tutorial with example class to see how I can make it running.
Thank you

suggestion: better handling exceptions

Right now, as we know, pokemon go server are.. well.. disappointing 💃

while login, as opened on prev ticket we can now see

E/PokemonGo: Failed to get profile data and update inventory
com.pokegoapi.exceptions.RemoteServerException: com.google.protobuf.InvalidProtocolBufferException: Contents of buffer are null

that's a e.printStackTrace.

can i suggest to remove all the printStackTrace and replace them with throw new Throwable(something) or even better throw new CustomException, like ServerKaput!

it's useful for custom error handling & logging purpose

catch pokemon doesn't work

Hello,

i have try this little piece of code to try to catch pokemon on my area.
distance return meters of distance from go.getLat/lon to pokemon.getLat/long with all
the supposed radiant sin cos stuff.

i check that the pokemon it's close to the current location, but catchResult return always fail.
on log i can see some json running around (probably a sleep will be better)

it's not working right now or i am doing something of wrong?

 Collection<CatchablePokemon> pokemons = go.getMap().getCatchablePokemon();
            for (CatchablePokemon pokemon : pokemons) {
                if (distance(go,pokemon) <0.5) {
                    for (int i = 0;i<10;i++) {
                        CatchResult r = pokemon.catchPokemon();
                        if (r.isFailed())
                        {
                            dbg("fail");
                        }
                    }
                }
            }

getMapObjects doesn't return all objects (pokestop)

it's correct to do

while (true) {
go.setLocation(lat, long, h);
go.getMap().getMapObjects(1);
lat+=SOMETHING;
long+=SOMETHING;
}

i am not getting all the results from getPokestops, and i am sure of that cos i am testing on the same area :)

Fix namespaces

Right now, when you include this in another project, you need to have these imports

import auth.GoogleLogin;
import api.PokemonGo;

I think it would be better to put everything in a correct namespace so you can easily see what you have imported in other projects (instead of the names above).

Gracefully retry requests

Instead of having these big try/catch blocks (and then returning null data), I think the API should not just dump the stacktrace to the console, but either automatically retry after some time, or return that it failed and should be retried later.

don't see a license on the project

Guys is there a license on this project?
GPL/Apache/MIT ?
Having the license on the homepage would simplify things for people like me who are eager to play with this. :)
Cheers.

Legal Issues, thoughts?

Here are some of the legal terms that could be related to the API, thoughts?

(iii) Use, or facilitate the use of, any unauthorized third-party software (e.g. bots, mods, hacks, and scripts) to modify or automate operation within the Service whether for yourself or for a third party.
(v) Download quantities of content to a database for any reason;
(vi) Decompose, disassemble, or reverse engineer any part of any Service, or otherwise use a Service for any purpose other than those provided for by us and in conjunction with the operations of the Service;
(vii) Develop functionally similar products or services to any Service;
(xiii) Attempt to circumvent any restriction in any Service based upon age, geography, or other restriction imposed by us.

Source: http://www.pokemon.com/us/terms-of-use/

UnmodifiableCollection.addAll error when getting MapObjects

Stacktrace:
java.lang.UnsupportedOperationException
W/System.err: at java.util.Collections$UnmodifiableCollection.addAll(Collections.java:932)
W/System.err: at com.pokegoapi.api.map.MapObjects.addDecimatedSpawnPoints(MapObjects.java:54)
W/System.err: at com.pokegoapi.api.map.Map.getMapObjects(Map.java:127)
W/System.err: at com.pokegoapi.api.map.Map.getMapObjects(Map.java:86)
W/System.err: at com.pokegoapi.api.map.Map.getMapObjects(Map.java:74)
W/System.err: at com.pokegoapi.api.map.Map.getMapObjects(Map.java:43)

Occurs when calling PokemonGo.getMap().getMapObjects(lat, long)

Pokemon Data From Encounter Result

Is there any way to add a method to EncounterResult where it returns the pokemon information (WildPokemon and CaptureProbability) so it's possible to judge what to do before trying to catch it?

Ex: Get the CP from the pokemon so it's possible to use different balls to catch it?

java.lang.NoClassDefFoundError

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/protobuf/MessageOrBuilder
at com.pokegoapi.auth.PTCLogin.login(PTCLogin.java:160)

unable to catch pokemon

After moving to the suggested api, i am unable to catch pokemon.

can someone explain the difference between
MapPokemon
and
WildPokemon

tnx

Nearby pokemons all at 200 meters ?

Trying the API and when I check the nearByPokemon it always says they are 200 meters away. Which is wrong as I can clearly a catchable poker just next to me.

Is this a bug of the server or the API ?

suggestion: catchPokemon with more options

Hi,

i see that catchPokemon support the ability to set certain pokeBall.

it will be great if you add the option for using the berry. Probably it's
already possible simply using the berry before using catchPokemon it's correct?

Also, another great options, will be (if necessary) to add the retry
feature for catchPokemon.

i think that CATCH_MISSED can be retryed, correct?
so, the correct 'flow' to catch a pokemon will be if result == CATCH_MISS catchPokemon();
or it's a final error?

so, my proposal, it's do add a method
catchPokemon(pokeBall,berryCt, retryCt)

that will use a custompokeball, a certain number of berries, and try for retryCt count.

Exception: Attempt to invoke virtual method 'com.google.protobuf.CodedInputStream com.google.protobuf.ByteString.newCodedInput()' on a null object reference

This just started in the last 24 hours with some updates to the repo and POGOProtos.

Running the following:
EnvelopesOuterClass.Envelopes.RequestEnvelope.AuthInfo auth = new PTCLogin(client).login(username, password); Log.d(LOG_TAG, auth.toString()); PokemonGoApi = new PokemonGo(auth, client);

Yields this:

java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.protobuf.CodedInputStream com.google.protobuf.ByteString.newCodedInput()' on a null object reference
System.err:     at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:104)
System.err:     at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:125)
System.err:     at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:130)
System.err:     at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
System.err:     at POGOProtos.Networking.Responses.GetPlayerResponseOuterClass$GetPlayerResponse.parseFrom(GetPlayerResponseOuterClass.java:230)
System.err:     at com.pokegoapi.api.PokemonGo.getLocalPlayer(PokemonGo.java:72)
System.err:     at com.pokegoapi.api.PokemonGo.getPlayerProfile(PokemonGo.java:89)
System.err:     at com.pokegoapi.api.PokemonGo.<init>(PokemonGo.java:53)
System.err:     at Application.loginTest(Application.java:32)

Sometimes it is yielding this exception as well:

com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.

Apologies if this is just simply that their API has changed over night.

I am almost ready to push to here a fully working Android version but I need to get this resolved.

License

What is this api licensed under? I'd like to use it but I need to know what all I can do with it first (e.g. commercial/noncommercial, etc.). I only ask because I couldn't find a License file or any other license notes anywhere. Thanks!

Logging

Should have logging through the API (esp for raw requests / responses) for easier debugging.

Thoughts?

Pokemon Proto

Java is not reading in the proto properly, all fields except one are fine (the important one too :|), the main ID for that pokemon. Its appearing as unrecognized field 1.

If anyone has any ideas, please let me know

Pokemon {
  PokemonId: 41
  Cp: 10
  Stamina: 10
  MaxStamina: 10
  Move1: 202
  Move2: 50
  HeightM: 0.7697427
  WeightKg: 6.7737203
  IndividualAttack: 12
  IndividualDefense: 1
  IndividualStamina: 9
  CpMultiplier: 0.094
  Pokeball: 1
  CapturedS2CellId: 3040700506126155776
  CreationTimeMs: 1468583377444
  FromFort: true
  1: 0x455da2ba068ba149
}

Does Login Work ATM?

I first tried with GoogleLogin but the request failed and got an exception.
Then I tried PTCLogin and again got a LoginFailedException.

I also tried again with the sample code and again got the same exception?

Service Unavailable

Hi when invoke login i receive this response, when call new PtcLogin(http).login

Response{protocol=http/1.1, code=503, message=Service Unavailable, url=https://sso.pokemon.com/503?locale=null}

There are problem with services ?
The username and password that i must provide is of my google account ?

NoHttpResponseException

I just tried this example:

auth = new GoogleLogin().login("username","password");
PokemonGo go = new PokemonGo(auth);
System.out.println(go.getPlayerProfile());

The authentications seems to work but i always end up with this exception:

org.apache.http.NoHttpResponseException: pgorelease.nianticlabs.com:443 failed to respond
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:143)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)
    at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)
    at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
    at com.pokegoapi.main.RequestHandler.sendRequests(RequestHandler.java:76)
    at com.pokegoapi.api.PokemonGo.getInventory(PokemonGo.java:64)
    at com.pokegoapi.api.PokemonGo.<init>(PokemonGo.java:35)
    at com.pokegoapi.api.Main.main(Main.java:13)

exception while go.getPlayerProfile(true)

while doing go.getPlayerProfile(true) (after begin logged)

it throw this excepiton

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:653)
    at java.util.ArrayList.get(ArrayList.java:429)
    at com.pokegoapi.main.RequestHandler.sendServerRequests(RequestHandler.java:119)
    at com.pokegoapi.api.PokemonGo.getPlayerAndUpdateInventory(PokemonGo.java:101)
    at com.pokegoapi.api.PokemonGo.getPlayerProfile(PokemonGo.java:154)


it's even possible that's correct, but will be better imho if it throw something more understandable or a custom exception?

PlayerStatsProto issues

except the first 4 fields are required
the rest should be all optional.

for example, if a player never entered any gym. His response of NumBattleAttackWon NumBattleAttackTotal etc does not exist. I have tested and confirmed.

The API prints stacktraces, instead of throwing errors

An API should always throw the exception to the user, instead of just printing a stack and ignoring it.

Example:

        try {
            go = new PokemonGo(auth, http);
        } catch(Exception ex) {
            Logger.error("Servers appear to be down");
            ex.printStackTrace();
            System.exit(1);
        }

Won't do shit, because you only print the stack, which makes it impossible for the API user to handle errors while the servers are down...

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.