World of Warships API Command

Hi im new in creating commands. What i can do to make it works
idplayer: $(eval a= $(urlfetch json https://api.worldoftanks.eu/wot/account/list/?application_id=f7dcd080fd60db07d2dde3edb966c637&search=$(querystring)); Informations: $(a))

Hey @exred!

What data do you want out of this?

{"status":"ok","meta":{"count":6},"data":[{"nickname":"ExReD","account_id":505079924},{"nickname":"Exred57","account_id":555505419},{"nickname":"exred90","account_id":526220582},{"nickname":"ExRed_1","account_id":526521907},{"nickname":"exredcap","account_id":501092509},{"nickname":"ExreDD","account_id":562646233}]}

it is supposed to be a primitive command that throws raw data from this page with id and then a similar command that loads games and won games \ nick is XsensualX

{ā€œstatusā€:ā€œokā€,ā€œmetaā€:{ā€œcountā€:1},ā€œdataā€:[{ā€œnicknameā€:ā€œXsensualXā€,ā€œaccount_idā€:558592195}]}

Well, we could do all that in one command I thinkā€¦
What is the other link of the API?

after $(eval a= $(https ://api.worldofwarships.eu/wows/account/statsbydate/?application_id=f7dcd080fd60db07d2dde3edb966c637&fields=pvp.battles%2C+pvp.wins&account_id=$(querystring)); Informations: $(a))
this id from first command input to this second query and again throw raw data

Alright, I finally had time to work on this! So this will be done like this:
First command is !stats, you can give it another name if youā€™d like:

!addcom !stats -a=_stats $(eval id=$(urlfetch json https://api.worldoftanks.eu/wot/account/list/?application_id=f7dcd080fd60db07d2dde3edb966c637&search=$(querystring)).data[0].account_id)

And then you have the alias _stats:

!addcom _stats $(eval d=$(urlfetch json https://api.worldofwarships.eu/wows/account/statsbydate/?application_id=f7dcd080fd60db07d2dde3edb966c637&fields=pvp.battles%2C+pvp.wins&account_id=$(query)).data[$(query)].pvp[$(time Etc/UTC "YYYYMMDD")]; `Number of PVP battles: ${d.battles} | Number of wins: ${d.wins} | Success rate: ${Math.round(d.wins/d.battles*10000)/100}%`)

Note: if you change the name of the first command (!stats), I recommend changing the name of the alias (_stats) to match, in which case youā€™ll have to change the -a=_stats part in the first command to match as well.

Add these commands from the chat, and now if you do !stats XsensualX, it should give you a result like this: Number of PVP battles: 1095 | Number of wins: 568 | Success rate: 51.87%

My only concern is the possibility that they donā€™t use the UTC time zone to store the data, in which case it could result in some errors, let me know if it fails at some point, but I doubt it will.

2 Likes

Thx for it, but idk why
Nightbot

: Cannot read property ā€˜battlesā€™ of undefined

do you have any idea why it doesnt work?

Is the problem that your trying to search through an array with the square brackets and there is no array?

Hi @potatoeaterlove
Then what should I do

We have to use brackets because the key names are numbersā€¦ This API is badly designed.

Iā€™ll look into it today, I was busy these last days. Itā€™s weird thoā€™ because I tested it and it was working fine.

Quick question, but nonetheless important: what is your current time zone, and did you just play?
Itā€™s currently 12:25pm UTC+2 and the API got updated recently, especially the date, I would like to know if itā€™s because you played a game, or if the date changed because the API servers updated it.
If possible, I would prefer if you could give me your time zone in the UTC+/-n format.

My time is CEST
Im from Poland

Iā€™m not sure what the issue was, but nevertheless I changed API endpoint because I want as less number keys as possible, theyā€™re such a mess to deal with. And the data with the link you provided seems to change only when someone plays a game, so the date is an issue because itā€™s not predictable, but we need it to be consistent otherwise itā€™s gonna break a lot. So I picked another endpoint of the API, thatā€™s not date-dependent.

!addcom !stats -a=_stats $(eval id=$(urlfetch json https://api.worldofwarships.eu/wows/account/list/?application_id=f7dcd080fd60db07d2dde3edb966c637&search=$(querystring)).data[0].account_id)
!addcom _stats $(eval d=$(urlfetch json https://api.worldofwarships.eu/wows/account/info/?application_id=f7dcd080fd60db07d2dde3edb966c637&account_id=$(query)).data;n=d[$(query)].nickname;pvp=d[$(query)].statistics.pvp;`${n} statistics - Number of PVP battles: ${pvp.battles} | Number of wins: ${pvp.wins} | Success rate: ${Math.round(pvp.wins/pvp.battles*10000)/100}%`)

You could also get the number of draws and losses with pvp.draws and pvp.losses respectively.

And a screenshot to prove itā€™s working:

Ok. Thx a lot it works.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.