NightDev Community Forums

Warzone Last 5 Games Codtracker API Command

If possible I’d like some assistance in trying to create a Nightbot command from codtracker API.
What I’d like to do is display the last 5 Lobby KD values and potentially use those values to create an average KD of those lobbies as well.
e.g. Last 5 Lobby KD’s: 1.24 | 1.20 | 1.23 | 1.36 | 1.13. Average Lobby KD: 1.23
^ obviously the above values are just examples taken from the codtracker I’m trying to use, but that’s how I’d want it to look. I have created an API command previously with help from several threads but this one I can’t quite figure out myself and I couldn’t find any other threads that were close enough to what I’m looking for.


Thank you in advance for any help!

Hey @jimbojambo303!

I imagine you just want to get the average of the 5 last matches regardless of the game mode:

$(eval m=$(urlfetch json; m.length=5;>m.attributes.avgKd.kd); a=Math.floor((r.reduce((a,b)=>a+b)/5)*100)/100; `Last 5 lobby KDs: ${r.join(' | ')}. Average lobby KD: ${a}`)

Basically, I first pull all the matches from the API, then only keep the last 5 matches, after that I get the KD for each match, then I compute the average KD and round it to two decimal places.

Link to the main Warzone API topic

1 Like

You’re amazing thank you so much!

1 Like

Will this command work for everyone as long as we change the API link in the command?

Hey @Hurlockk!

Yes, it would, you just need to change the last part of the URL: atvi/username%231234567: %23 is the #, so here the user is username#1234567.
Make sure to convert the # into %23, and change the service if your ID isn’t an Activision ID (atvi), but I’ve heard everyone migrated to that now.