-
Notifications
You must be signed in to change notification settings - Fork 12
Usage
npm install pogobuf-vnext --save
npm install git+https://github.com/pogosandbox/pogobuf.git
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
or pogobuf.GoogleLogin
class) and call init()
to make an initial request.
Example usage with PTC login:
const pogobuf = require('pogobuf-vnext');
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
});
Example usage with Google login:
const pogobuf = require('pogobuf-vnext');
var login = new pogobuf.GoogleLogin(),
client = new pogobuf.Client();
login.login('username', 'password')
.then(token => {
client.setAuthInfo('google', token);
client.setPosition(lat, lng);
return client.init();
}).then(() => {
// Make some API calls!
return client.getInventory(0);
}).then(inventory => {
// Use the returned data
});
For more details, see the API documentation or the example scripts.
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]
});
You can find more examples in the examples directory.