I was looking through the documentation for the v5 API, and noticed a lot of them use the id (e.g user, channel, etc) to retrieve the specific object. But there’s no indication of where to get these ids… I was able to find how to get the user’s id by querying via login name, but that is not the case for say a channel.
Seems kind of counter productive that to get an object of something we have to use the id, but there’s no clear guide on where to get these id - unless I’m not seeing it.
A user’s channel id is equal to his user id.
EDIT: you can also get multiple at once by comma delimiting the channel names
@DallasNChains I did see that section during my search. Does that format apply to everything else (e.g channel, video, etc)? Meaning I can use
/...?login=<videoname> or whatever to get the id of something?
@bvec No. Each object has an
_id field that is returned from the API as appropriate. For example, the Get Top Videos endpoint has
_id in the response for each video object. You can then pass that into the Get Video endpoint. The endpoint noted above was created to help ease the transition between v3 and v5 by translating between username (v3) to ID (v5).
@DallasNChains Right, so that brings me back to my original question: How to get the id of something?
E.g https://dev.twitch.tv/docs/v5/reference/videos/#get-video - Let’s say I want to get a specific video (not a top video), how would I know where to get the id?
It seems for a user and channel, I can use
.../?login=<user|channel name> to get the object which should have the _id field. But what about other objects like video, communities, etc
Get Community by name.
You can’t get a video by its name. You can get videos for a channel by using the channel ID.
@bvec I’m not sure if I’m understanding your question. For example, you can use Get Channel Videos and each video in the response has
_id. That ID is what you pass into Get Video. A similar pattern applies to all objects in the API.
@DallasNChains Okay that answers my question. So there’s no straight forward way to get an id of something. I’d have to make several calls beforehand and look through the responses.
Is there a reason for that? Why not have to id readily available for lookup like in a video’s URL or something.
The URL of a video does have the ID. For example, https://www.twitch.tv/videos/127550310. That number at the end is the ID. You can call https://api.twitch.tv/kraken/videos/127550310/ with a Client-ID and get information about that video.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.