API

From Earth Empires Wiki
Jump to: navigation, search

An API key is used to access in-game news feeds such as ranks, news and market data. This information can then be used to create community-based sites similar to Boxcar or EEstats. There are many different sites that use this game data to benefit their alliance or the community in general.

Contents

How to get an API key

If you would like access to game feeds, you must request an API key from qzjul or Pang, in #earthempires (IRC), or on the Earth Empires forums. If you are granted a key, it must remain private. Do not give your API key to ANYBODY!

Usage

Once you have an API key, the data is fairly easy to acquire. A simple HTTP request can be used to access this data which is sent in a CSV format. It is then up to the developer's discretion as to how to parse and display the data for human consumption.

Here is a simple example written in perl.

Feeds

These are the different feeds and the information they display.

Ranks

http://www.earthempires.com/ranks_feed

gives a list of all the countries & their basic information; example of current preferred format serverid,resetid,rank,number,name,land,networth,tag,gov,gdi,protection,vacation,alive,deleted currently throttled to 300s polling

News

http://www.earthempires.com/news_feed

lists news events & information as they happen; example of current preferred format: serverid,resetid,newsid,timestamp,type,win,attacker_num,attacker_name,defender_num,defender_name,result1,result2,a_tag,d_tag,killhit currently throttled to 1s polling

Market

http://www.earthempires.com/market_feed

lists the current state of the market; example of current format: serverid,typeid,cost,amount,standing order price currently throttled to 1s polling; This feed is only if you want a snapshot of current prices; if you want to log transactions please use the transactions feed...

Transactions

http://www.earthempires.com/mtrans_feed

lists the market transactions (purchases) as they happen: example of current format: serverid,resetid,transactionid,time,goodid,price,quantity,standing_order_purchase(this is a bool) currently throttled to 1s polling; This feed is the preferred feed for determining market transactions;

General Information

http://www.earthempires.com/apicode_info

Lists whether you're using gzip encoding and various hit stats and information.

Request Format

Once you have a key, you will be granted permission to a forum which is dedicated to helping and answering developers' questions. All updates concerning the API and it's use are noted here. Developers should check this often. There are many examples of how to properly use the API. it is highly recommended you learn about .gzip compression with the use of your platform to help EE conserve bandwidth.

All feeds take ?apicode=(your apicode) for the feed itself, and without that argument have a help page if you go to it in your browser.

Server ID Numbers

Each server has a numerical value (serverid):

ID# Server
8 Express
9 Alliance
10 Team
11 Primary
12 FFA

News Type Numbers

Each hit types has a numerical value (type):

ID# News Type
1 Standard Strike
2 Planned Strike
5 Guerilla Strike
6 Bombing Run
7 Artillery Barrage
10 Nuclear Missile
11 Chemical Missile
12 Cruise Missile