Custom Valorant API Noob Issue

So I’ve got live JSON data, but I have no idea how to pull it. It looks like this.

{
 "PlayTime": "98H 02M Play Time",
 "MatchesPlayed": "173 Matches",
 "KADRatio": "1.25",
 "DamagePerRound": "132.7",
 "KDRatio": "0.91",
 "Headshots": "13",
 "WinRate": "48.0%",
 "TotalWins": "83",
 "TotalKills": "2,256",
 "TotalHeadshots": "1,187",
 "TotalDeaths": "2,473",
 "TotalAssists": "827",
 "ScorePerRound": "196.5",
 "KillsPerRound": "0.6",
 "Clutches": "253",
 "Flawless": "175",
 "MostKillsPerMatch": "25",
 "AccuracyHead": "16.6%",
 "AccuracyBody": "77.2%",
 "AccuracyLegs": "6.2%",
 "AccuracyHeadHits": "253",
 "AccuracyBodyHits": "1178",
 "AccuracyLegsHits": "94",
 "TopWeapon1": "Vandal",
 "TopWeapon2": "Ares",
 "TopWeapon3": "Frenzy",
 "TopWeapon1Kills": "1,172",
 "TopWeapon2Kills": "413",
 "TopWeapon3Kills": "167",
 "TopAgent1": "Killjoy",
 "TopAgent2": "Raze",
 "TopAgent3": "Skye"
}

I just want to pull one at a time…pepehands

I’ve tried

$(eval a=$(urlfetch json LINK);Response here with stats ${a.PlayTime})

$(eval ($(urlfetch json LINK)).PlayTime)

$(eval try{a=$(urlfetch json LINK);b=a.PlayTime[0];(b.PlayTime+|+b.example).replace(/[[]]/g,``).replace(/[\n\r]/g, ).slice(0,400);}catch(e){No search result found!;})

$(eval r=decodeURIComponent("$(querystring $(urlfetch json LINK))");try{JSON.parse(r).PlayTime}catch(e){Failed to parse API response: ${e.message}: ${r}.slice(0,400)})

Nothing has worked :frowning: I just want to say like “Total Playtime [playtime from data]” etc

Hey @nigel5000!

I doubt you posted the full JSON response? If this is not the full output, please send it in full, so we can help effectively. Consider censoring sensible content, don’t delete the "key": "value", just replace the value by DESCRIPTIVE_TEXT.

Also, consider checking this other post that’s addressing a similar issue to yours, it could help greatly:

Thank you for the linked suggestion, I’ll certainly take a look!

That is the full copy/paste from the API url, which I can’t provide because it includes my tokens/api keys. It’s from parsehub since I’m grabbing data from a webpage. It says it’s formatted as JSON and when I go to jsonlint it says it’s valid? So I’m really confused. Format is below.

https://parsehub.com/api/v2/projects/TOKEN/last_ready_run/data?api_key=KEY

I feel like I’m getting close because I found that this seems to work with other data but not mine?

$(eval ($(urlfetch json LINK)).DATA)

So I’m not sure what’s happening and it’s super frustrating, it keeps saying Invalid or unexpected token.

EDIT: Apparently the site says this - “The Content-Encoding of this response is always gzip.” - if that helps?

The reason I linked you to the other topic is for you to see how to reach desired data with a JSON file, as it seems to be the issue here. If the JSON you posted in your first message is exactly what you get from the API, then you’re not far off. Where you got it wrong is that you surround the $(urlfetch) with parenthesis, the following should work:

$(eval $(urlfetch json API_LINK).JSON_KEY)

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