Black Ops 4 Stats API data fetch

Hi,

I am trying to get my head around how to pull a specific string of information from a Black Ops 4 stats API.

The API itself is https://cod-api.tracker.gg/v1/standard/bo4/profile/6/Marre-2788 and the specific string of information I would want to collect would be Stats 14 (Win %) and then the value.

I have only very limited knowledge of coding, and what I have tried have just failed as I don’t really know what I am doing.

Where would I even begin with this? I believe it should be a geturl, but after that I do not understand how I get the sub-string of the API url…

If anyone could help I would be very grateful

@marreuk

Use $(eval) to turn the info from the API into a JS object:

!addcom -cd=5 !winpercent $(eval a=JSON.parse(`$(urlfetch json https://cod-api.tracker.gg/v1/standard/bo4/profile/6/Marre-2788)`);a.data.stats[14].displayValue)
1 Like

Amazing! Thank you kindly, it works like a charm :slight_smile:

How can I get more then one string without using the same $(eval) twice in an command?
Let’s say for data.stats[15] and [14]

@orloko

!addcom -cd=5 !winpercent $(eval a=JSON.parse...;a.data.stats[14].displayValue+` `+a.data.stats[15].displayValue)
1 Like

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