Wargaming Public API – Part 2

Source: http://habrahabr.ru/company/wargaming/blog/229475/

Part 1http://ftr.wot-news.com/2014/07/14/wargaming-public-api-part-1/

Internal interaction of the API components background

To understand the principle of how WG API works, it’s worth looking at how the internal information flows are made, how the distribution of data is secured, their relevance etc. – this part is shortly decribing the internal component interaction organization.

Our entire infrastructure for games is built around the service model, which means the components are relatively independent and interact with each other using the API sets. This is due to several factors:

- even if something crashes, everything else keeps on working
- there are many components (authentication service, OpenID provider, rating systems, clan services, Clanwars, Wargaming league, game portals, forums, wiki, support and so on, altogether around 40 components)
- components are developed by different teams
- components are not released all at once
- complete shutdown of the entire system during updates is unacceptable

It’s obvious that to release a new version of two-three components, which are developed separately is significantly easier than to release of an entire huge system. Apart from that, the development of separate components as smaller functional elements is simplier than the management of the entire system.

Principles of interaction

In our infractructure, there are two main flows of data: calls of remote API methods and another system (game server, other components) event subscription.The API component is most often represented by HTTP REST API. The API call can return the answer both synchronously and asynchronously. For asynchronous responses, we use Message Broker (RabbitMQ in our case) via AMQP protocol.

Subscriptions also happen via RabbitMQ. As an example of subscription, we can mention the export of game player account status after changes in it. Apart from that, for example, after every battle the dossier of the player tank which the battle was played with is exported into MQ. This allows the game portal to show the up-to-date player statistics (well, almost), all that while the game server recieves no additional load. In order to show the way our components interact, a picture (the upper part in cyrillic says “component”)

80c42ea3cc038dbaea3dc91559cdecd0

This picture doesn’t represent the reality completely, as we have no service bus as such. Every component is aware where the API of other components it needs is located and they interact directly, without any intermediaries. Roughly the same picture is with the event bus – every component knows how to connect directly to the broker to recieve or publish various data.

Public API is the same component in this infrastructure as any other. There are perhaps some differences – it is for example tied to a relatively large amount of other services, eg. considering structural design patterns, it appears as a “facade” of the entire system. Of course, Public API is not only proxy-service, it has its own additional logic, it can cache and save some sets of data in order to optimize the response speed and to reduce the load on the internal system. It also has to check the access rights and to monitor the demand limits of various applications, to collect statistics etc. Since the API is public, a large part of the code is there to protect the internal API’s and isolate them from the external users.

Some statistics

With the introduction of Public API, WG solved at least one problem – very high load on WG resources, which made WG life miserable periodically, was reduced. It was transferred to API instead, where it is easier to control and easier to secure the reliability of the system as a whole. Some up-to-date numbers from Russian cluster:

API METHOD calls in 7 days
api.worldoftanks.ru/wot/account/tanks ~13 800 000
api.worldoftanks.ru/wot/account/info ~13 100 000
api.worldoftanks.ru/wot/tanks/stats ~7 360 000
api.worldoftanks.ru/wot/ratings/accounts ~5 800 000
api.worldoftanks.ru/wot/clan/info ~3 800 000

Users, who entered the Developer’s Corner since the start of the program: 63750
Registered application keys: 12029

Currently, there are more than 200 active applications. Some are very good, with much time and effort invested, such as:

- mobile application “WoT Knowledge Database”
- portal wot-news
- various noobmeters
- clan sites
- statistic sites vbaddict, wot-info, wotlabs and others
- sites with CW info
- game mods such as XVM

Not all sites use API, but some would benefit from it. Last note: Wargaming is not against developers making money off their applications.

3 thoughts on “Wargaming Public API – Part 2

  1. Very nicely translated SS, good job.
    Also an example of WG doing something right.