How to get the id of something?

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.

Anyone know?


A user’s channel id is equal to his user id.

Use the /users?login=<channelname> endpoint

EDIT: you can also get multiple at once by comma delimiting the channel names

@bvec There is a section dedicated to it here:

1 Like

@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 or _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). :slight_smile:

@DallasNChains Right, so that brings me back to my original question: How to get the id of something?

E.g - 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, That number at the end is the ID. You can call with a Client-ID and get information about that video.

1 Like

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