Difference between revisions of "ChatWars API"

From ChatWars Wiki
Jump to: navigation, search
(added pseudo code; minor changes)
(Bring up to date with current API state)
 
Line 3: Line 3:
 
Possible actions are:
 
Possible actions are:
 
*receive (listen to)
 
*receive (listen to)
**stock exchange updates (offers/deals)
+
**[[Exchange|stock exchange]] updates (offers/deals)
**current lowest offers per item (sex_digest)
+
**current lowest offers per item on [[Exchange|exchange]] (sex_digest)
 
**list of open shops ([[Yellow Pages|yellow_pages]])
 
**list of open shops ([[Yellow Pages|yellow_pages]])
 +
**battle results in the [[Arena|arena]] (duels)
 +
**active and recently finished [[Auction|auction lots]] (au_digest)
 
*interact with player accounts (needs authorization)
 
*interact with player accounts (needs authorization)
 
**request player profile / stock information
 
**request player profile / stock information
 
**retrieve and make payments (pouches only)
 
**retrieve and make payments (pouches only)
**make buy requests in name of player (wtb/sniping)
+
**make buy requests in name of player on the [[Exchange|exchange]] (wtb/sniping)
 +
**request player's ([[Craftbook|craftbook]])
 +
**request player's ([[Guild|guild]]) (excluding member list)
  
 
== Technology ==
 
== Technology ==
Line 15: Line 19:
  
 
== API access ==
 
== API access ==
Request for API access via [https://t.me/ChatWarsFeedbackBot @ChatWarsFeedbackBot]. 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. If you didn't get feedback within a day, request again.
+
Request for API access via [mailto:support@chtwrs.freshdesk.com 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 <code>john</code> and your app name be <code>myapp</code>, then the created username might look like <code>john_myapp</code> and then the queues are named like <code>john_myapp_deals</code>, <code>john_myapp_yellow_pages</code> or <code>john_myapp_i</code>.
 
Depending on your request there are queues created for your username. Let your telegram name be <code>john</code> and your app name be <code>myapp</code>, then the created username might look like <code>john_myapp</code> and then the queues are named like <code>john_myapp_deals</code>, <code>john_myapp_yellow_pages</code> or <code>john_myapp_i</code>.
Line 47: Line 51:
 
*[https://t.me/cwapi Developers Castle Chat] (only for real developers, sometimes rude.)
 
*[https://t.me/cwapi Developers Castle Chat] (only for real developers, sometimes rude.)
 
*[https://t.me/chtwrsapi ChatWars API updates channel]
 
*[https://t.me/chtwrsapi ChatWars API updates channel]
*[https://hackmd.io/s/Hk60PGm0z CW API v0.6]
+
*[https://chatwars.github.io/chatwars-api-docs/ Official API Documentation]

Latest revision as of 07:15, 28 March 2019

ChatWars API

The ChatWars API is the official way to interact with the game programmatically. Possible actions are:

  • receive (listen to)
  • interact with player accounts (needs authorization)
    • request player profile / stock information
    • retrieve and make payments (pouches only)
    • make buy requests in name of player on the exchange (wtb/sniping)
    • request player's (craftbook)
    • request player's (guild) (excluding member list)

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