Tribal wars public api?

Reaction score
1
hello i have a question about tribalwars "api"


i dont manage to understand how twstats makes tools like this
http://www.twstats.co.uk/ukc1/index.php?page=map

cause noone of the public apis that are here :https://forum.tribalwars.us/index.php?threads/world-data.5996/)

offers data about to what tribe belongs each village

i asked my server Comunnity Manager and he tells me that twstats dosnt have any privileged info, so basically my conclusion is that the post is outdated/there are not all api calls information there?
 

JawJaw

Awesomest CM Ever
Reaction score
2,210
It does contain that information, though.

Village information contains:
$village_id, $name, $x, $y, $player_id, $points, $rank

With $player_id, you can link it to player information, which contains:
$player_id, $name, $tribe_id, $villages, $points, $rank

And then just use tribe_id to get the tribe name:
$tribe_id, $name, $tag, $members, $villages, $points, $all_points, $rank

So basically you can use some INNER JOIN 's, if you're tech savvy and know SQL, to figure it out.
 
Upvote 0

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
621
The publicly available world data is composed from a set of text files (probably not the best of choices but thats fro another time to discuss).

There are:
- village.txt
- ally.txt
- player.txt
- etc...

With only these 3 you can get the list of players, villages and tribes on a world.

Now you ask how is it possible to list villages belonging to a tribe when neither ally.txt or village.txt does not directly make this connection.

Because entities or connected together like this.

Village -> Player -> Tribe

So you get a Tribe's player's list. Then for each Player you get its village's list, etc (all based on player id, tribe id, village id, etc).

All of this can be done as JawJaw said using JOINs in SQL or 2 separated SQL queries (dont see why not using JOIN's though other then the fact that they are usually hard to grasp for newer programmers).

Red.
 
Upvote 0

Gregy

New Member
Reaction score
0
Hi
The publicly available world data is composed from a set of text files (probably not the best of choices but thats fro another time to discuss).

There are:
- village.txt
- ally.txt
- player.txt
- etc...

Can you developp the "etc..." ? :D

Is there any way to know conquests ? Ty
 
Upvote 0

RedAlert

Senior In-Game Staff
Tribal Wars Team
Senior
Team
Script Moderator
Reaction score
621
Hello @Gregy ,

Yes it is possible to fetch conquests too from this endpoint:
Code:
/map/conquer.txt
/map/conquer.txt.gz (this is recommended whenever possible)
(Includes all conquered villages since start of the world)

This endpoint gives back a response following this format:
$village_id, $unix_timestamp, $new_owner, $old_owner

Also if you need only conquests from a specific time:
Code:
/interface.php?func=get_conquer&since=unix_timestamp
(This function allows to see the last conquered villages since the last Unix timestamp. The timestamp can go back 24 hours max.)

The reponse format is the same as above:
$village_id, $unix_timestamp, $new_owner, $old_owner

Hope this helps.
 
Upvote 1

DaWolf85

Non-stop Poster
Reaction score
583
Full list of possible endpoints, plus data structuring where necessary:
Code:
/map/village.txt
/map/village.txt.gz
(Data: id, name, x, y, player, points, rank)

/map/player.txt
/map/player.txt.gz
(Data: id, name, ally, villages, points, rank)

/map/ally.txt
/map/ally.txt.gz
(Data: id, name, tag, members, villages, points, all_points, rank)

/map/conquer.txt
/map/conquer.txt.gz
(Data: village_id, unix_timestamp, new_owner, old_owner)

/map/kill_att.txt
/map/kill_def.txt
/map/kill_sup.txt
/map/kill_all.txt
(Data: rank, id, kills)

/map/kill_att_tribe.txt
/map/kill_def_tribe.txt
/map/kill_all_tribe.txt
(Data: rank, id, kills)

/interface.php?func=get_conquer&since=unix_timestamp
(Data: village_id, unix_timestamp, new_owner, old_owner)
(NOTE: unix_timestamp value can be no more than 24 hours ago)

/interface.php?func=get_config

/interface.php?func=get_unit_info

/interface.php?func=get_building_info

Rules for using this data:
- It is recommended to pull the .gz version if possible.
- With the exception of the get_conquer function, these are updated once per hour, and thus should not be requested more frequently (users who ignore this risk being banned from the endpoints).

It is also worth noting that some older players/script creators may remember a profile.txt endpoint. This has been removed due to GDPR. It is no longer possible to pull profile data.
 
Upvote 1

kozmicz

New Member
Reaction score
1
is it possible to read somewhere how many barbarian and bonus villages are planned in the settings? I couldn't find it anywhere.
/interface.php?func=get_config

in this settings it missing.
 
Upvote 0

JawJaw

Awesomest CM Ever
Reaction score
2,210
Do we have any way of getting "Days played on world by player"? I believe we can estimate it by using conquer info and player's first occurrence in the data (it is more or less 1-2 weeks on the world for example), better than nothing but maybe I miss something.

Hi,

This data is not available directly, but you could indirectly get it by storing the player.txt permanently and add a column "first seen" on insert. That would match with +/-1h on when that player came on the world.

There is no other way of achieving this.
 
Upvote 0

xxxxx77

New Member
Reaction score
0
Thanks! :)

I am going to implement this column indeed, just in case. But that means this kind on data will be only useful for the worlds in the future with the indication that the world's data about players will be followed (scraped) from the very beginning to the end, without interruptions every hour :)
With kind of serious bugs in case of errors in implementation or problems with updates :D

Not really a solution but at least something. And may be helpful for ppl who will read this thread planning creating wrapper API for game's data ;)
 
Upvote 0

MKich

Member
Reaction score
6
/interface.php?func=get_conquer&since=unix_timestamp
(Data: village_id, unix_timestamp, new_owner, old_owner)
(NOTE: unix_timestamp value can be no more than 24 hours ago)

Just FYI there is also a /interface.php?func=get_conquer_extended&since=unix_timestamp endpoint

Similar to the
/map/conquer_extended.txt
/map/conquer_extended.txt.gz
files

This is the structure:
$village_id, $unix_timestamp, $new_owner, $old_owner, $old_tribe_id, $new_tribe_id, $points_of_village


Does anyone know if that data https://forum.tribalwars.net/index.php?threads/tribe-ods-rankings.282453/ is available in the api (and if yes where) ?
 
Upvote 0
Top