The Feeds of eRepublik API
Languages: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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
Error feed |
---|
<error>
<time> 2010-05-04T18:12:24+02:00 </time>
<message> invalid id '10000' </message> </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
Citizen feed |
---|
<citizen>
<is-president> If the citizen is president of the country </is-president>
<citizenship>
<region>
<name> The name of the region of citizenship </name>
<id> The Id of the region of citizenship </id> </region> <country> </citizenship> <code> The code of the country of citizenship </code>
<name> The name of the country of citizenship </name>
<id> The Id of the country of citizenship </id> </country> <military-skills>
<military-skill> <level> The level of the military skill </level>
<name> The name of the military skill </name>
<points> The number of point of the military skill </points> </military-skill> ... </military-skills> <level> The level of the citizen </level>
<is-congressman> If the citizen is congressman of the country </is-congressman>
<avatar-link> The URL adress of the citizen avatar </avatar-link>
<residence>
<region>
<name> The name of the region of residence </name>
<id> The Id of the region of residence </id> </region> <country> </residence> <code> The code of the country of residence </code>
<name> The name of the country of residence </name>
<id> The Id of the country of residence </id> </country> <experience-points> The number of experience points of the citizen </experience-points>
<is-organization> If the citizen is a organization </is-organization>
<date-of-birth> The date of birth of the citizen </date-of-birth>
<employer>
<name> The name of the employer </name>
<id> The Id of the employer </id> </employer> <wellness> The Health of the citizen </wellness>
<medals>
<medal> <type> The type of the medal </type>
<amount> The amount of medals </amount> </medal> ... </medals> <military>
<rank> The name of the military rank </rank>
<total-damage> The total of damage made by the citizen </total-damage>
<rank-points> The points of rank </rank-points>
<fight-count> The count of fight </fight-count>
<stars> The number of stars </stars> </military> <name> The name of the citizen </name>
<happiness> The happiness of the citizen </happiness>
<party>
<president> If the citizen is party president </president>
<name> The name of the party </name>
<id> The Id of the party </id> </party> <id> The Id of the citizen </id>
<is-general-manager> If the citizen is a general manager </is-general-manager>
<sex> The sex of the citizen </sex> </citizen> |
Countries
Returns information about all countries.
URLs
http://api.erepublik.com/v2/feeds/countries
XML output
Countries feed |
---|
<countries>
<country> <average-citizen-level> The average of citizen level of the country </average-citizen-level>
<citizen-count> The count of citizen of the country </citizen-count>
<code> The code of the country </code>
<continent> The continent of the country </continent>
<currency> The currency of the country </currency>
<id> The id of the country </id>
<name> The name of the country </name>
<region-count> The number of regions of the country </region-count>
<regions> </country> <region> <name> The name of the region </name>
<id> The id of the region </id> </region> ... </regions> ... </countries> |
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
Country feed |
---|
<country>
<average-citizen-level> The average of citizen level of the country </average-citizen-level>
<citizen-count> The count of citizen of the country </citizen-count>
<code> The code of the country </code>
<continent> The continent of the country </continent>
<currency> The currency of the country </currency>
<id> The id of the country </id>
<name> The name of the country </name>
<region-count> The number of regions of the country </region-count>
<regions> </country> <region> <name> The name of the region </name>
<id> The id of the region </id> </region> ... </regions> |
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
Region feed |
---|
<region>
<buildings>
<defense-systems>
<defense-system> </defense-systems> <area-of-effect> The Area of effect of the Defense system </area-of-effect>
<customization-level> The Customization level of the Defense system </customization-level>
<defense-bonus> The Defense bonus of the Defense system </defense-bonus>
<durability> The Durability of the Defense system </durability> </defense-system> <hospitals> </buildings> <hospital> </hospitals> <area-of-effect> The Area of effect of the hospital </area-of-effect>
<customization-level> The Customization level of the hospital </customization-level>
<max-heal-per-citizen> The Max-Heal per citizen of the hospital </max-heal-per-citizen>
<wellness-budget> The wellness budget of the hospital </wellness-budget> </hospital> <country>
<id> The id of the country </id> </country> <citizen-count> The count of citizen of the region </citizen-count>
<id> The id of the region </id>
<name> The name of the region </name>
<neighbours>
<neighbour> <region>
<id> The id of the neighbour region </id> </region> <country> </neighbour> <id> The id of the neighbour country </id> </country> ... </neighbours> <raw-materials> </region> <raw-material> <name> The name of the raw-material </name>
<productivity> The productivity of the raw-material </productivity> </raw-material> ... </raw-materials> |
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
Citizens by region feed |
---|
<region>
<citizens>
<citizen> <id> The Id of the citizen </id> </citizen> ... </citizens> <citizen-count> The count of citizen of the region </citizen-count>
<current-page> The current page of the feed </current-page>
<id> The id of the region </id>
<page-count> The count of page of the feed </page-count> </region> |
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
Company feed |
---|
<company>
<employees>
<employee> <skill>
<id> The Id of the skill </id> </skill> <name> The Name of the employee </name>
<id> The Id of the employee </id>
<country> </employee> <id> The Id of the country </id>
<name> The Name of the country </name>
<code> The Code of the country </code> </country> ... </employees> <stock> The Stock of the company </stock>
<is-for-sale> If the company is for sale </is-for-sale>
<customization>
<wellness> Customization point of wellness </wellness>
<happiness> Customization point of happiness </happiness>
<durability> Customization point of durability </durability>
<moving-distance> Customization point of moving-distance </moving-distance>
<defense> Customization point of defense </defense>
<area-of-effect> Customization point of area-of-effect </area-of-effect>
<damage> Customization point of damage </damage>
<attack> Customization point of attack </attack> </customization> <region>
<name> The Name of the region </name>
<id> The Id of the region </id> </region> <raw-materials-in-stock> The number of Raw materials in stock </raw-materials-in-stock>
<export-licenses>
<export-license> <is-active> If the export licence is active </is-active>
<industry>
<name> The Name of the export Industry </name>
<id> The Id of the export Industry </id> </industry> <country> </export-license> <id> The Id of the country </id>
<name> The Name of the country </name>
<code> The Code of the country </code> </country> ... </export-licenses> <job-offers>
<job-offer> <number-of-jobs> The number of jobs </number-of-jobs>
<required-skill> The required skill of the offer </required-skill>
<salary> The salary of the offer </salary>
<skill-id> The Id of the skill </skill-id>
<industry>
<name> The Name of the export Industry </name>
<id> The Id of the export Industry </id> </industry> <country> </job-offer> <id> The Id of the country </id>
<name> The Name of the country </name>
<code> The Code of the country </code> </country> ... </job-offers> <name> The Name of the company </name>
<industry>
<name> The Name of the industry </name>
<id> The Id of the industry </id> </industry> <id> The Id of the company </id>
<customization-level> The customization level of the company </customization-level>
<country> </company> <id> The Id of the country </id>
<name> The Name of the country </name>
<code> The Code of the country </code> </country> |
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
Exchange market feed |
---|
<offers>
<offer> <amount> The amount of currency </amount>
<exchange-rate> The exchange rate </exchange-rate>
<seller> </offer> <citizen>
<name> The name of the citizen </name>
<id> The id of the citizen </id> </citizen> <company> </seller> <name> The name of the company </name>
<id> The id of the company </id> </company> ... </offers> |
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
Market feed |
---|
<offers>
<offer> <company>
<id> The id of the company </id> </company> <customization>
<wellness> Customization point of wellness </wellness>
<happiness> Customization point of happiness </happiness>
<durability> Customization point of durability </durability>
<moving-distance> Customization point of moving-distance </moving-distance>
<defense> Customization point of defense </defense>
<area-of-effect> Customization point of area-of-effect </area-of-effect>
<damage> Customization point of damage </damage>
<attack> Customization point of attack </attack> </customization> <amount> The amount of the offer </amount>
<price> The price of the offer </price> </offer> ... </offers> |
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
War feed |
---|
<war>
<is-resistance> if the war is a resistance war </is-resistance>
<proclaimed-by>
<allies>
<ally> <code> The code of the country </code>
<name> The name of the country </name>
<id> The id of the country </id> </ally> ... </allies> <code> The code of the country </code>
<name> The name of the country </name>
<id> The id of the country </id> </proclaimed-by> <progress>
<started-at> Date of the start of the war </started-at>
<finished-at> Date of the end of the war </finished-at>
<finished-reason> The reason of the end of the war </finished-reason> </progress> <proclaimed-to>
<allies>
<ally> <code> The code of the country </code>
<name> The name of the country </name>
<id> The id of the country </id> </ally> ... </allies> <code> The code of the country </code>
<name> The name of the country </name>
<id> The id of the country </id> </proclaimed-to> <active-battle-count> Number of active battle </active-battle-count>
<id> The id of the war </id>
<battles> </war> <battle> <id> The id of the battle </id> </battle> ... </battles> |
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 feed |
---|
<battle>
<is-resistance> if the war is a resistance war </is-resistance>
<combatant-count> The number of combatant </combatant-count>
<attacker>
<damage-dealt> The number of damage by the country </damage-dealt>
<code> The code of the country </code>
<units-killed> The number of units killed </units-killed>
<name> The name of the country </name>
<id> The id of the country </id> </attacker> <progress>
<started-at> The date of start </started-at>
<finished-reason> The reason of the end </finished-reason>
<finished-at> The date of the end </finished-at> </progress> <war>
<id> The id of the war </id> </war> <defender>
<damage-dealt> The number of damage by the country </damage-dealt>
<code> The code of the country </code>
<units-killed> The number of units killed </units-killed>
<name> The name of the country </name>
<id> The id of the country </id> </defender> <region>
<name> The name of the region </name>
<id> The id of the region </id> </region> <id> The id of the war </id>
<winner> The id of the winner country </winner> </battle> |
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
Battle combatants feed |
---|
<combatants>
<combatant-count> The total number of combatants </combatant-count>
<page-count> The total number of pages </page-count>
<current-page> The current page </current-page>
<combatants> </combatants> <combatant> <deaths> The number of death ? </deaths>
<damage-dealt> The number of damage did </damage-dealt>
<residence-country-id> The id of the residence country </residence-country-id>
<citizen-id> The id of the citizen </citizen-id>
<fights> The number of fights </fights>
<kills> The number of opposent killed </kills> </combatant> ... </combatants> |
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; ?>