The Feeds of eRepublik API

From eRepublik Official Wiki
Jump to: navigation, search
Languages: 
EnglishIcon-English.png


Speech balloon.png Menu

Contents


Feeds are simple resources that can be requested directly without any authorization.

For example, you can go here with your browser, http://api.erepublik.com/v2/feeds/countries to get an XML list of all countries.

Data formats

The eAPI can transparently output XML (which is the default) or JSON data formats. By default, the response will be formatted in XML. For most calls, the data format can simply be chosen by appending .xml or .json to the call.

example :

http://api.erepublik.com/v2/feeds/countries/1
http://api.erepublik.com/v2/feeds/countries/1.xml

both return information about Romania (country-id 1) in xml.

http://api.erepublik.com/v2/feeds/countries/1.json

returns information about Romania (country-id 1) in json.

All the below examples will deal with XML data because it's more human readable. Feel free to always use the JSON format if you prefer it!

Errors

When the eAPI encounters an error, it will usually return an error element containing a time and a message element. Calling the following url

http://api.erepublik.com/v2/feeds/countries/10000

will result in the following error


These errors are meant for debugging purposes only, so if the eAPI returns such a response, the only information for your application should be “there was an error” - do not use the message for anything other than reading it yourself.

Feeds

The eAPI data feeds let you retrieve various information about the game. No registration or authentication is required to use the feeds. To use a feed, simply make an HTTP GET request to the appropriate url.

Citizen

Returns information about one citizen. The citizen can be retrieved by either his/her id or his/her citizen name. The name parameter of the citizen_by_name call is not case sensitive. Note that for the citizen_by_name call, you have to specify the format (either xml or json) before the name parameter.

URLs

http://api.erepublik.com/v2/feeds/citizens/<id>
http://api.erepublik.com/v2/feeds/citizen_by_name/<format>/<name>

Examples

http://api.erepublik.com/v2/feeds/citizens/1450324
http://api.erepublik.com/v2/feeds/citizen_by_name/xml/Azaret
http://api.erepublik.com/v2/feeds/citizen_by_name/json/admin

Note that citizen names can contain special characters, you should therefore always URL escape the name before making the request, replacing all special characters with their corresponding URL escape code. The name “fresh!==!dude” would become “fresh%21%3D%3D%21dude”. Otherwise, the eAPI will not recognize some names.

XML output



Countries

Returns information about all countries.

URLs

http://api.erepublik.com/v2/feeds/countries

XML output


Country

Returns information about one country by its country id. For detailed information about the regions of a country, see regions by country. For detailed information about the wars a country is involved in, see wars by country.

URL

http://api.erepublik.com/v2/feeds/countries/<id>

Example

http://api.erepublik.com/v2/feeds/countries/1

XML output


Region

Returns information about one region by its globally unique region id. To get information about the citizens/inhabitants of a region, see citizens by region.

URL

http://api.erepublik.com/v2/feeds/regions/<id>

Example

http://api.erepublik.com/v2/feeds/regions/9

XML output


Regions by country

Returns detailed information about the regions of a country. Each region looks exactly like a region returned by the Region call.

URL

http://api.erepublik.com/v2/feeds/countries/<id>/regions

Example

http://api.erepublik.com/v2/feeds/countries/1/regions

Wars by country

Returns information about the wars a country is involved in. Each war looks exactly like a war returned by the War feed.

URL

http://api.erepublik.com/v2/feeds/countries/<id>/wars

Example

http://api.erepublik.com/v2/feeds/countries/1/wars

Citizens by region

Returns the citizen-ids of all the citizens living in this region. This list can get very large and is therefore paginated. The current page, total number of pages and total number of citizens in this region are returned on each page. Note that the page numbers are zero-indexed.

URL

http://api.erepublik.com/v2/feeds/regions/<id>/citizens/<page>

Example

http://api.erepublik.com/v2/feeds/regions/9/citizens/0

XML Output


Company

Returns information about one company.

URL

http://api.erepublik.com/v2/feeds/companies/<id>

Example

http://api.erepublik.com/v2/feeds/companies/182533

XML Output



Exchange market

The currency exchange market (or monetary market) feed provides information about monetary exchange offers. The currencies that you specify are not case sensitive. This call does only return the 10 best offers for the requested exchange. Note that each country (see Countries) has one currency and there's the GOLD currency in addition.

URL

http://api.erepublik.com/v2/feeds/exchange/<buy_currency>/<sell_currency>
  • buy_currency : The currency that you want to buy.
  • sell_currency : The currency that you want to sell.

Example

http://api.erepublik.com/v2/feeds/exchange/RON/GOLD

XML Output


Market

The market feed provides information about product offers, filtered by their attributes.

URL

http://api.erepublik.com/v2/feeds/market/<industry_id>/<country_id>/<attr_1>/<attr_2>/<a ttr_3>/<attr_4>
  • industry_id : The id of the industry in which you want to look for products. See the industries feed for information about the industry ids.
  • country_id: the id of the country in which you want to look for products.
  • attr_1 – attr_4 : These correspond to the attributes of the product and state the minimum value the product should have at this attribute. Products have different number of attributes (0 to 4), and you must specify the correct number. The order of the attributes is the order they are returned in the industries feed.

Example

http://api.erepublik.com/v2/feeds/market/1/39/10/20

XML Output


Industries

Returns Information about all industries and their customizable attributes. The attributes are returned in the same order the market feed takes them.

URL

http://api.erepublik.com/v2/feeds/industries

War

Returns information about one war. For detailed information on the battles fought in this war, see battle by war.

URL

http://api.erepublik.com/v2/feeds/wars/<id>

Example

http://api.erepublik.com/v2/feeds/wars/91

XML Output


Battle

Returns information about a battle. For information on the combatants fighting in the battle, see combatants.

URL

http://api.erepublik.com/v2/feeds/battles/<id>

Example

http://api.erepublik.com/v2/feeds/battles/1

XML Output



Battle by war

Returns all battles that were or are fought in a specific war. Each battle looks exactly like a battle from the Battle call.

URL

http://api.erepublik.com/v2/feeds/wars/<id>/battles

Example

http://api.erepublik.com/v2/feeds/wars/639/battles

Battle combatants

This feed was for the second version of the war module during eRepublik Rising, so this feed work only for battles which were during the second version.


Returns information about combatants of a battle. This feed is paged. The current page, total number of pages and total number of combatants in this battle are returned on each page. Note that the page numbers are zero-indexed.

URL

http://api.erepublik.com/v2/feeds/battles/<id>/combatants/<page>

Example

http://api.erepublik.com/v2/feeds/battles/1/combatants/2

XML Output


Uses

Google Documents

You can use the eAPI on a Google Spreadsheet document, for this you have to use the ImportXML function, like this :

=ImportXML("http://api.erepublik.com/v2/feeds/citizens/1450324.xml","/citizen/name")

This cell will contain the name of the citizen 1450324

You can use the function with a node of the feed like that :

=ImportXML("http://api.erepublik.com/v2/feeds/citizens/1450324","/citizen")

Google Docs will put all child's nodes info on the line, one child per cell.

image:http://img.skitch.com/20100728-q8xr79ad64dtedjcrmfcbgipp9.jpg

Php

You can use many methods for parse XML in PHP, you can find some of ones here : XML Manipulation

You can use DOM (Document Object Model) for PHP 5 & 6 :

<?php
  $xmlDoc = new DOMDocument();
  $xmlDoc->load('http://api.erepublik.com/v2/feeds/citizens/1450324');
  $xp = $xmlDoc->getElementsByTagName("experience-points")->item(0)->nodeValue;
?>
Personal tools
Namespaces
Variants
Actions
Wiki
Miscellaneous
Editors
Toolbox