ChatWars API
ChatWars API
The ChatWars API is the official way to interact with the game programmatically. Possible actions are:
- receive (listen to)
- stock exchange updates (offers/deals)
- current lowest offers per item on exchange (sex_digest)
- list of open shops (yellow_pages)
- battle results in the arena (duels)
- active and recently finished auction lots (au_digest)
- interact with player accounts (needs authorization)
Technology
The API is based on AMQP, a message queuing protocol. The used implementation is RabbitMQ.
API access
Request for API access via email. You have to specify an "application" name (username), which queues you want to listen to and which grants you want to have. You get a username and a password. Requests may take some time to be fulfilled.
Depending on your request there are queues created for your username. Let your telegram name be john
and your app name be myapp
, then the created username might look like john_myapp
and then the queues are named like john_myapp_deals
, john_myapp_yellow_pages
or john_myapp_i
.
You don't have to declare any queues yourself or bind them to fanout exchanges. Trying so will result in error. Just consume your individual queues.
Pseudo code listening on deals exchange:
// create connection with properties: // useSslProtocol = true // host = "api.chatwars.me" // port = 5673 // virtualhost = "/" connection := createAMPQConnection( "amqps://api.chatwars.me:5673/", "john_myapp", "passwordViaChatwarsfeedbackbot") // get a channel from the connection channel := connection.createChannel() // a consumer receives the messages from the queue; programm logic is going to be there consumer := createNewMyConsumer() // setting autoAck = true means every message is immediately acknowledged when a consumer recieves it // set autoAck = false if you want the server to redeliver the messages on failure, but you HAVE TO acknowledge every message within consumer manually then! autoAck := true // attach consumer to queue of fanout exchange deals (everything is already declared and bound) channel.basicConsume("john_myapp_deals", autoAck, consumer)) // keep programm running forever ...
Further help
- Developers Castle Chat (only for real developers, sometimes rude.)
- ChatWars API updates channel
- Official API Documentation