World Data/API?

DeletedUser

Guest
Hi guys is there going to be an exported world data/api as in tribal wars? I used to use this for my own map tools etc and would love to use this for this game to.
 

DeletedUser

Guest
Well, the german grepolis has already a twstats version, http://www.grepolismaps.org/, it only has maps. So, i'm sure that the data will be available soon for the public too, i don't know if that site is connected whit grepolis or independent, made by a fan.
You can ask the guy that has the site how he got the world data.
 

DeletedUser

Guest
Odd that links working for me when I click it however I will put the info here.

Grepolis - World Data

We have written this small guide for other developers who wish to utilise the Grepolis World Data to create their own websites. A good example of what this data can be used to do is Grepo Stats. All data is currently available in the JSON format. Currently world data is updated hourly. Each world's data will be updated at a random starting minute.

Note: Please use the compressed world data whenever possible.
Player data
- players.json
- players.json.gz

The player data contains the following information:

* id - The internal ID of the player
* name - The player's name
* alliance_id - The player's internal alliance ID (see alliances.json)
* points - The player's current amount of points
* rank - The player's current rank
* towns - The player's current amount of cities

Alliance data
- alliances.json
- alliances.json.gz

The alliance data contains the following information:

* id - The internal ID of the alliance
* name - The alliances's name
* points - The alliance's current amount of points
* rank - The alliance's current rank
* towns - The alliances's current amount of cities
* members - The alliances's current member count

Town data
- towns.json
- towns.json.gz

The town data contains the following information:

* id - The internal ID of the town
* player_id - The owner of the town. NULL if no owner
* name - The town's name
* island_x - The X coordinate of the island the town is on
* island_y - The Y coordinate of the island the town is on
* number_on_island - The position of the town on it's island
* points - The town's points

Island data *large file*
- islands.json
- islands.json.gz

The islands data file contains the information for the world's islands. Please note that this is a large file and that once a world has started, it's contents will not change. Therefore, you do not need to keep downloading this file!
The island data contains the following information:

* id - The internal ID of the island
* x - The X position of the island
* y - The Y position of the island
* island_id - The internal number of the island, or, what 'type/size/shape' of island this is. 1-10 = player islands with farm towns, 11-16 = uninhabited islands, 17-21 = rocks

Player kill data
- player_kills.json
- player_kills.json.gz

The player kill data contains information about the player 'kill' ranking. There is a record for each player who is ranked. Each record is an array of objects, with the keys 'all', 'att', 'def'. These keys mean: 'Overall', 'As attacker', 'As defender'.
Each of the aforementioned objects contain the following data:

* rank - The rank for the specific type
* player_id - The internal ID of the player
* points - The points/score

Alliance kill data
- alliance_kills.json
- alliance_kills.json.gz

The alliance kill data contains information about the alliance 'kill' ranking. There is a record for each alliance that is ranked. Each record is an array of objects, with the keys 'all', 'att', 'def'. These keys mean: 'Overall', 'As attacker', 'As defender'.
Each of the aforementioned objects contain the following data:

* rank - The rank for the specific type
* alliance_id - The internal ID of the alliance
* points - The points/score

Colonisation data
- conquers.json
- conquers.json.gz

The colonisation data contains the following information:

* town_id - The town's internal ID
* time - The UNIX timestamp of the conquer
* new_player_id - The player who colonised the town
* old_player_id - If involved, the player who lost the town. Otherwise, NULL
* new_ally_id - If in an alliance, the alliance ID of the player who colonised the town. Otherwise, NULL
* old_ally_id - If in an alliance, the alliance ID of the player who lost the town. Otherwise, NULL
* town_points - The town's points at the time of the colonisation

Building, unit and research information
- units.json
- units.json.gz
- buildings.json
- buildings.json.gz
- researches.json
- researches.json.gz

All links point to http://de1.grepolis.de however http://en1.grepolis.net works so for example http://en1.grepolis.net/data/units.json
 

DeletedUser

Guest
Legend of a fella :)
That info will be of great help to many people and will bring about some very useful new tools :D
 

DeletedUser

Guest
lol well I cant take credit for the info I just found it and guessed the correct url for our world :D

Now I just need to have a play with importing the JSON files into an SQL database :p all good fun
 

DeletedUser

Guest
They are basically text files, that gives a name of an object, the variables for that object and the values of those variables.

{"a":{"b":1,"c":2}}

This basically says there's an object called a, it has the variable of b which has a value of 1 and another variable of c which has a value of 2. Each of these objects are separated by comma's.

For example for the for the first 1 units in the game you would have the following:

{"militia":{"id":"militia","attack_type":"pierce","attack":2,"def_hack":3,"def_pierce":4,"def_distance":2,"speed":0,"resources":null,"favor":0,"population":0,"kill_points":0,"build_time":1,"god_id":null,"research_dependencies":null,"building_dependencies":null,"description":"Militia","name":"Militia"},"sword":{"attack_type":"hack","attack":5,"def_hack":14,"def_pierce":8,"def_distance":30,"booty":16,"speed":8,"resources":{"wood":95,"stone":0,"iron":85},"favor":0,"population":1,"kill_points":1,"build_time":1080,"god_id":null,"research_dependencies":[],"building_dependencies":null,"id":"sword","description":"Swordsmen form your city's basic defense: weak at attacking, very good at defending against remote warriors and good against blunt weapons, inexpensive unit.","name":"Swordsman"}}

I don't know if I have the terminology right I have only just started looking into this but there's plenty of information on google on how JSON files are formatted and how to handle them.

Hope this helps.
 

DeletedUser

Guest
lol well I cant take credit for the info I just found it and guessed the correct url for our world :D

Now I just need to have a play with importing the JSON files into an SQL database :p all good fun
I assume you are able to do it and have probably done the same for tw before, but if you can't let me know and I will put together an example file :)
How can I open JSON files then?
Open it in a normal text editor.
Its really meant for using to build a tool or even a spreadsheet, not much use unless you are going to use it for some type of tool they are usually very big and sometimes hard to understand.

EDIT: Damn I hate when I don't notice the thread has moved on to another page :)
 

DeletedUser

Guest
I fixed the worlddata link.

If you're using PHP this should give you a good idea of how to use the data:

PHP:
$dataFile = file_get_contents('http://en1.grepolis.net/data/units.json');
$data = json_decode($dataFile);
echo "<pre>";
print_r($data);
echo "</pre>";

This will covert the data file into objects. If you'd rather work with arrays, just use: json_decode($dataFile, true);
 

DeletedUser

Guest
Ok a question how woulsd you use this like you would the tw data through mysql etc?
 

DeletedUser

Guest
Ok a question how woulsd you use this like you would the tw data through mysql etc?
Its almost exactly the same as how you upload, write and read the data as in tw.
The only difference is this is json and Squelch has told you how to handle that above.
 

DeletedUser

Guest
I think I might leave all that scripting stuff to the scriptsperts. ;)
 

DeletedUser

Guest
Its almost exactly the same as how you upload, write and read the data as in tw.
The only difference is this is json and Squelch has told you how to handle that above.

But the way he does it does that extract it as a text file or what?
 

DeletedUser

Guest
$dataFile = file_get_contents('http://en1.grepolis.net/data/units.json');
Gets a file and returns it as a string.
$data = json_decode($dataFile);
that takes a json file formatted as a string as outputs it as an object.

Basically two problems with it,
1) It doesn't use the .gz compressed file, which you use on tw
2) What is an object :p but like squelsh has told us using json_deocde($data, true) returns the json file as an array.
 

DeletedUser

Guest
To be honest getting the data is the simple part :) I will never say people shouldn't ask question's and learn but in the long run it doesn't matter what you do with the data its what you do with it once you have it that matter's.

The obvious tool is of course mapping tools (I know there are ones already out there but great for learning to do ourselves). But then what else can you do with the data? that's where the fun comes in.

On TW I used to have war tool's, you go to war with a tribe enter their name into the tool and it would give you maps of both tribes, list's of which of your tribe members are closest to their members. Compared points to work subdivided people into suggested attack groups, noble flagging so you can see at a glance which villages nobles are being sent towards.

It was all ugly as sin because Im not good with graphical presentation but the fun for me was the backend :) Its going to be interesting to see what tools people come up for this world.
 
Top