Home

Awesome

agario-client

Node.js client for agar.io with API.

Outdated!

Agar developers made completely new code for game. Now code runs inside virtual machine that I can not reverse-engineer due to lack of knowledge and experience. Unfortunately its time to say goodbye to agario-client. Initial idea of agario-client was for me to learn websockets, binary protocols, reverse-engineering, github and have fun overall. I believe that I achieved all that. Thanks to all, it was great time!

Instructions

API

There are two types of object that have API:

Both objects have same methods for events from events.EventEmitter:

Client API

var AgarioClient = require('agario-client');
var client = new AgarioClient(client_name);

client_name is string for client that will be used for logging (if you enable it). It's not your ball name.

Client properties

Properties that you can change:

Properties that better not to change or you can break something:

Client methods

Client events

In this list on.eventName(param1, param2) means you need to do client.on('eventName', function(param1, param2) { ... })

Ball API

var ball = client.balls[ball_id]; ball_id is number that you can get from events

Ball properties

Properties that you can change:

Properties that better not to change or you can break something:

Ball methods

Ball events

In this list on.eventName(param1, param2) means you need to do ball.on('eventName', function(param1, param2) { ... })

Servers

When you do var AgarioClient = require('agario-client'); you can access AgarioClient.servers Functions need opt as options object and cb as callback function.

Servers options

All functions can accept: opt.agent to use for connection. Check additional info opt.local_address local interface to bind to for network connections (IP address of interface) opt.resolve set to true to resolve IP on client side (since SOCKS4 can't accept domain names) opt.ip if you resolved m.agar.ip IP by other way (will cancel opt.resolve).

Check region list below in this file.

Servers callbacks

Callback will be called with single object that can contain:

LOOKUP_FAIL can happen only if opt.lookup was set to true and will have only error_source

You can check how examples/basic.js uses this.

Additional information

agario-devtools

If you want record/repeat or watch in real time what your client doing through web browser, you might want to check agario-devtools

Regions list

Ball destroy reasons list

Auth token

To login into your account you need to request token. You can check example in examples/auth_token.js First create new AgarioClient.Account

var account = new AgarioClient.Account();

Then you need to login through facebook on http://agar.io then go to http://www.facebook.com/ and get cookies c_user,datr,xs. Here is list of properties of account:

Then you call

account.requestFBToken(function(token, info) {
	//If you have `token` then you can set it to `client.auth_token` 
    // and `client.connect()` to agar server
});

If token is null, then something went wrong. Check info which can contain:

SOCKS/Proxy support

You can change default agent for AgarioClient and AgarioClient.servers to use for connections. You can use libs to do it. For testing and example i used socks lib. Execute node ./node_modules/agario-client/examples/socks.js to test it and read examples/socks.js file to see how to use SOCKS. For proxy you will need to use some other lib.

Adding properties/events

You can add your own properties/events to clients/balls. var AgarioClient = require('agario-client');

For example:

AgarioClient.Ball.prototype.isMyFriend = function() { ... };  //to call ball.isMyFriend()
AgarioClient.prototype.addFriend = function(ball_id) { ... }; //to call client.addFriend(1234)

Events:

client.on('somebodyAteSomething', function(eater_id, eaten_id) {  #eat event
    if(client.balls[eaten_id].isMyFriend()) { //if this is my friend
        client.emit('friendEaten', eater_id, eaten_id); //emit custom event
    }
});
client.on('friendEaten', function(eater_id, friend_id) { //on friend eaten
    client.log('My friend got eaten!');
});

Check full example in examples/basic.js

Feedback

If something is broken, please email me or create issue. I will not know that something is broken until somebody will tell me that.

License

MIT