Question about a warzone custom API command (daily stats)

I recently ran across this post:

The code at the bottom of the post shows how to obtain stats for the “last 20 matches” off the cod tracker site. Is it possible to fix the number of matches it counts, based on the “timestamp”? The API does seem to track the data by date (in “timestamp”), and my idea is to only capture data for “today”. For example, only count the segments for Sept 1st 2021.

Here’s a sample api:

https://api.tracker.gg/api/v2/warzone/matches/battlenet/Scop3s%232625

Hiya, you could compare the matches[x].metadata.timestamp to the date of today, however seems like the API returns 20 matches. Not sure if there are parameters to fetch more matches, but this means if you played more than 20 games that day the command will be inaccurate.

2 Likes

Thanks for the quick reply. I’m pretty new to JSON. Is it possible you can show me a little more of what I need to do?

I imagine that there is a script that allows me to capture the first 10 characters of the value of timestamp (2021-09-01). Then, to set the value of “today”, I imagine I can grab the first match’s timestamp so that it’s dynamic.

And yes, unfortunately that is the data we have (last 20 matches). Most of the people I mod for though do not play more than 20 games a day :slight_smile:

1 Like

Just a quick update, been messing around with the code and I think I’m halfway there:
Command:
‘$(eval m=$(urlfetch json https://api.tracker.gg/api/v1/warzone/matches/battlenet/Scop3s%232625/).data.matches; tt=“09-01”; t=m[0].metadata.timestamp.substring(5,10); k=d=r=w=0;p=[];for(i=0;i<20;i++){y=m[i].metadata; s=m[i].segments[0].stats; p.push(y.mapName,y.timestamp.substring(5,10),s.placement.value);}p.forEach(e=>e==1?w++:``);Time: ${tt} | Times2 ${w} I ${i} K ${k} P ${p} ;)’

Nightbot returns:
Time: 09-01 | Times2 7 I 20 K 0 P Rebirth Island,09-02,7,Rebirth Island,09-02,1,Rebirth Island,09-02,5,Verdansk,09-01,14,Verdansk,09-01,10,Verdansk,09-01,28,Verdansk,09-01,12,Verdansk,09-01,1,Verdansk,09-01,3,Verdansk,09-01,2,Verdansk,09-01,1,Verdansk,09-01,36,Verdansk,09-01,1,Verdansk,09-01,6,Verdansk,09-01,1,Verdansk,09-01,1,Verdansk,09-01,1,Verdansk,09-01,28,Verdansk,09-01,62,Verdansk,08-31,2

The first few values are just for me to check stuff. What I’m most interested in is the list of the 20 matches with mapName, “date”, and placement. I want to count only the ones that are Verdansk, 09-01, 1. I’m still having trouble figuring out how to use “forEeach”. Any help would be greatly appreciated :slight_smile: :slight_smile:

1 Like

Filtering the date might be tricky because of timezones, however here’s an example you can play with:

$(eval
    m=$(urlfetch json https://api.tracker.gg/api/v1/warzone/matches/battlenet/Scop3s%232625/).data.matches;
    k=d=w=0;
    for(i=0;i<m.length;i++){
        s=m[i].segments[0].stats;
        if(s.placement.value == 1 && m[i].metadata.mapName == 'Verdansk' && m[i].metadata.timestamp.startsWith('2021-09-06')){
            k+=s.kills.value;
            d+=s.deaths.value;
            w++;
        }
    }
    `Wins: ${w} | Kills: ${k} | Deaths: ${d} | Kills/Deaths Ratio: ${Math.round((k/d)*100)/100}`;
)
2 Likes

Nice! I actually played with it a couple of days and found something that worked. However, this helps a lot because I realize now I may not need the array or “push” code. I’ll have to change it up, but here’s what I did (using a link shortener to save characters):

$(eval m=$(urlfetch json https://cutt.ly/eWW5O18/).data.matches;
t=m[0].metadata.timestamp.substring(5,10);k=d=w=0;p=[];
for(i=0;i<20;i++){y=m[i].metadata;s=m[i].segments[0].stats; if((y.timestamp.substring(5,10)===t)&&(y.mapName==="Verdansk")){p.push(s.placement.value);k+=s.kills.value;d+=s.deaths.value;}}p.forEach(e=>e==1?w++:``);
`Daily stats: ${w} wins | ${k} kills | ${Math.round((k/d)*100)/100} KD`;)
1 Like

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