Phildo
Phildo

Reputation: 1066

how to use twitch emote API

Here's a site ( https://twitchemotes.com/apidocs ) that shows an API to get twitch emotes (basically, json describing a set of images belonging to various users).

The API looks simple enough- but they have no examples of requests. So, for this example call ( https://twitchemotes.com/api_cache/v3/subscriber.json ), it returns a huge amount of data.

How do I narrow the request to a single channel?

The website has that example URL, and an example response, but no info on how to request a single channel. So, I assume there's some common knowledge I should be drawing from to be able to derive how to do so? Unfortunately, I apparently lack this knowledge. What am I missing?

Upvotes: 3

Views: 6822

Answers (3)

Ali
Ali

Reputation: 152

api.twitch.tv is gone.

You can also use this API: https://twitchemotes.com/apidocs

Upvotes: 0

Andrew Bashore
Andrew Bashore

Reputation: 86

You get emotes for a specific channel you need to make two requests:

  1. http://api.twitch.tv/api/channels/:channel_name/product

You can use this request to resolve the emoticon set IDs for a channel. For most channels under the plan array you will have 3 objects that each contain one or more emoticon_set_ids arrays. For most channels there will be 3 total. Some channels without 3 tier subscriptions may not have a plan array so you can look at emoticons for that instead.

(This endpoint is not designed for 3rd party use but it works and probably won't change much. Need to send Kraken client ID.)

  1. https://api.twitch.tv/kraken/chat/emoticon_images?emotesets=:emoticon_set_list

(Kraken v3)

Take the 3 emoticon_set_ids values and append them as a comma separated list to the emotesets parameter.

I am owner of Twitchemotes and this is basically the process I use to update my index.

Upvotes: 2

Alca
Alca

Reputation: 55

This URL can get you all of the emotes and plenty of other information:

https://api.twitch.tv/api/channels/timthetatman/product

where timthetatman is the username/login of a channel.

The emoticons property has only the first tier of emotes. You can get all of them in the plans object:

data.plans.reduce((p, n) => p.concat(n.emoticons), []);

You can get a direct URL in the emote object, but the preferred URL format would be like this:

https://static-cdn.jtvnw.net/emoticons/v1/123456/1.0

where 123456 is the emote ID and 1.0 is the scale. Scale can be 1.0, 2.0, or 3.0

let id = data.plans[0].emoticons[0].id;
let emoteURL = `https://static-cdn.jtvnw.net/emoticons/v1/${id}/1.0`;

Upvotes: 1

Related Questions