- Implements all known Pokémon Go API calls (Not all of them tested though)
- Uses ES6 Promises
- Includes Pokémon Trainer Club login client (Google login not yet implemented)
- Optional batch mode to group several requests in one RPC call
- Uses the excellent POGOProtos (via node-pogo-protos)
- Based on prior work by tejado and others
npm install pogobuf
Generally, every method that makes an API call returns an ES6 Promise that will be resolved with the response message object (or true
if there was no response message).
Before using a pogobuf.Client
instance to make API calls you need to supply it with an auth token (which you can get from the pogobuf.PTCLogin
class) and call init()
to make an initial request.
Example usage:
const pogobuf = require('pogobuf');
var login = new pogobuf.PTCLogin(),
client = new pogobuf.Client();
login.login('username', 'password')
.then(token => {
client.setAuthInfo('ptc', token);
client.setPosition(lat, lng);
return client.init();
}).then(() => {
// Make some API calls!
return client.getInventory(0);
}).then(inventory => {
// Use the returned data
});
See the API documentation below, or example.js for a more sophisticated example that does something useful.
The Pokémon Go API offers the ability to send multiple requests in one call. To do this you can use pogobuf's batch mode:
First call batchStart()
to enable batch mode. When in batch mode, all API request methods will append the request to the current batch instead of immediately sending it to the server. Once you have all your requests, call batchCall()
which submits them to the server, disables batch mode, and returns a Promise that will be resolved with an array of response messages corresponding to your requests.
When in batch mode, all API request methods (as well as batchStart()
) return the Client
instance so you can chain them.
Example batch usage:
client.batchStart()
.getPlayer()
.getHatchedEggs()
.getInventory(0)
.batchCall()
.then(responses => {
// responses is: [GetPlayerResponse, GetHatchedEggsResponse, GetInventoryResponse]
});
Sets the authentication type and token (required before making API calls).
Param | Type | Description |
---|---|---|
authType | string |
Authentication provider type (ptc or google ) |
authToken | string |
Authentication token received from authentication provider |
Sets the player's latitude and longitude.
Note that this does not actually update the player location on the server, it only sets
the location to be used in following API calls. To update the location on the server you
probably want to call updatePlayer
.
Param | Type | Description |
---|---|---|
latitude | number |
The player's latitude |
longitude | number |
The player's longitude |
Performs the initial API call.
Sets batch mode. All further API requests will be held and executed in one RPC call when batchCall
is called.
Clears the list of batched requests and aborts batch mode.
Executes any batched requests.
Sets a callback to be called for any envelope or request just before it is sent to the server (mostly for debugging purposes).
Param | Type |
---|---|
callback | function |
Sets a callback to be called for any envelope or response just after it has been received from the server (mostly for debugging purposes).
Param | Type |
---|---|
callback | function |
catchPokemon(encounterID, pokeballItemID, normalizedReticleSize, spawnPointID, hitPokemon, spinModifier, normalizedHitPosition)
⇒ Promise
downloadRemoteConfigVersion(platform, deviceManufacturer, deviceModel, locale, appVersion)
⇒ Promise
Performs the PTC login process and returns a Promise that will be resolved with the auth token.
Param | Type |
---|---|
username | string |
password | string |