Grepolis Data for NodeJS
This library provides a simple layer between Grepolis's world data files and your NodeJS project. The purpose is to provide a quick and minimal library that turns the CSV (and some JSON) data into objects that can easily be worked with in Javascript.
This library is intentionally created with zero external runtime dependencies.
Installation
npm i grepolis
Usage
Every function in the Grepolis library is named after the file which it reads (list below) to make things simple for developers working with the library. Each function returns a Promise containing the data that was read. In most cases this data is a really large array of objects. Every endpoint requires a server
variable which is just an object that contains the language and world number as seen in the example code.
As of 0.2.0
the functions have been divided between World
and Statistics
modules which can be imported individually with named imports or can be referenced via a single require
as shown below. Here is the new structure of the library:
- World
- units
- researches
- buildings
- Statistics
- towns
- islands
- conquers
- players
- playersKills
- playersKillsAttack
- playersKillsDefend
- alliances
- alliancesKills
- alliancesKillsAttack
- alliancesKillsDefend
Here is an example of reading towns data:
const Grepolis = require('grepolis');
/*
* Read all towns data from en110 (Leontini)
*/
const server = { lang: 'en', world: '45' };
Grepolis.Statistics.towns(server).then((data) => {
// data = array of towns
// this is a huge object list
console.log('Town Data: ', data);
});
Sample Data
Town
{
"id": "4775",
"playerId": "2182242",
"name": "cash+money",
"islandX": "496",
"islandY": "448",
"numberOnIsland": "5",
"points": "12090"
}
Island
{
"id": "117977",
"x": "5",
"y": "17",
"islandType": "40",
"availableTowns": "20",
"resourcePlus": "wood",
"resourceMinus": "stone"
}
Player
{
"id": "259495",
"name": "Thaylas",
"allianceId": "",
"points": "0",
"rank": "3100",
"towns": "0"
}
Alliance
{
"id": "124",
"name": "Terra+Nostrum",
"points": "6681",
"towns": "1",
"members": "1",
"rank": "146"
}
Conquer
{
"townId": "248",
"time": "1537879813",
"newPlayerId": "5037454",
"oldPlayerId": "",
"newAllyId": "28",
"oldAllyId": "",
"points": "4656"
}
Kills (player, alliance)
{
"rank": "278",
"id": "1847",
"points": "18"
}