Accessing 7TV API

Hi, I am trying to use Nightbot’s urlfetch json to read in all 7TV emotes and pick a random one. An example with a random channel would be

$(eval const d = $(urlfetch json `https://api.7tv.app/v3/emote-sets/01G0X6HFX8000EH87BCAZW2PPP)`; es=d.emotes; es[Math.floor(Math.random() * es.length)].name)

However urlfetch gives the error [Error Connecting To WebProxy Service]. What might the issue be?

For one, it looks like you have a typo in your url fetch variable:

$(eval const d = `$(urlfetch json https://api.7tv.app/v3/emote-sets/01G0X6HFX8000EH87BCAZW2PPP)`; es=d.emotes; es[Math.floor(Math.random() * es.length)].name)

I didn’t test this, so there could be more issues too

Oops, I am not sure how that happened when I copied it over, thank you! The command I have been trying out is the one you sent, and it still doesn’t work. I was wondering if the JSON response was too large (~2 MB), so I tested it out with a smaller emote set (~200 KB), and got a different error: [Error Connecting To WebEval Service]

It’s not clear if they’re blocking the requests, the response is taking too long, or the response is too large. 270KB is quite large for an API response though. You may want to build your own custom API to parse + cache their API response for Nightbot to consume in a more consistent and concise manner.

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