Putting Cod tracker stats as a command

Asked Oct 28, 2020·1 reply·Last activity 5 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Ive been trying to put a command using the call of duty API for my real time stats in nightbot. Here is the link of the public API:
https://my.callofduty.com/api/papi-client/stats/cod/v1/title/mw/platform/psn/…

Here is the command i used but its not filling in the stats:
$(eval a=JSON.parse(decodeURIComponent($(querystring $(urlfetch json https://my.callofduty.com/api/papi-client/stats/cod/v1/title/mw/platform/psn/…)))).data.lifetime.all.properties;Total Kills: ${a.kills} | Best KDR: ${a.bestKD} | Best Kill Streak: ${a.bestKillStreak} | Total Suicides: ${a.suicides} | Best Kills: ${a.bestKills} | Most Deaths: ${a.deaths})

Any help is appreciated.

1 reply

@Sugary Peacock Heya, welcome to the community. Your link is giving the error.

{"status":"error","data":{"type":"com.activision.mt.common.stdtools.exceptions.NoStackTraceException","message":"Not permitted: not authenticated"}}

By the way, if the link is working then I would code like this.
Ex. from documentation

$(eval
try {
api = $(urlfetch json https://my.callofduty.com/api/papi-client/stats/cod/v1/title/mw/platform/battle/gamer/iShot%2321899/profile/type/mp);
a=api.all.lifetime.properties;
"Total Kills: " + a.kills +
" | Best KDR: " + a.bestKD +
" | Best Kill Streak: " + a.bestKillStreak +
" | Total Suicides: " + a.suicides +
" | Best Kills: " + a.bestKills +
" | Deaths: " + a.deaths +
} catch (e) {
"ERROR"
}
)

If everything goes right, then the output would be like this...

Total Kills: 5891 | Best KDR: 7.5 | Best Kill Streak: 19 | Total Suicides: 32 | Best Kills: 78 | Deaths: 4550

...else it will give ERROR

I think it is problem with API. Hope this article help. :|

Edit: Sorry, I forgot to type $(URLFetch) variable