We are updating the Data API to match how YouTube counts views for Shorts.
Learn more
Implementation: Subscriptions
Stay organized with collections
Save and categorize content based on your preferences.
The following examples show how to use the YouTube Data API (v3) to perform functions related to subscriptions.
Retrieve a channel's subscriptions
Call the subscriptions.list
method to retrieve subscriptions for a particular channel. There are two ways to identify the channel:
See the subscriptions.list
method's documentation for code samples.
Add a subscription
Delete a subscription
This example deletes a subscription. This request must be authorized using OAuth 2.0. This example has two steps:
-
Step 1: Retrieve the subscriptions for the authenticated user's channel
Call the subscriptions.list
method to retrieve the list of subscriptions. The example above for retrieving a channel's subscriptions explains how to make this request.
The application calling the API could process the API response to display a list of subscriptions, using each subscription's ID as a key. In the response, each item's id
property identifies the subscription ID that uniquely identifies the corresponding subscription. You will use that value to remove an item from the list in the next step.
-
Step 2: Delete a subscription
Call the subscriptions.delete
method to delete a subscription. Set the request's id
parameter to the subscription ID for the subscription that you want to remove. This request must be authorized using OAuth 2.0.
To complete the request in the APIs Explorer, you need to set the id
property's value.
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.subscriptions.delete?
id=SUBSCRIPTION_ID
See the subscriptions.delete
method's documentation for code samples.
Retrieve a list of subscribers to the authorized user's channel
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[[["\u003cp\u003eThe YouTube Data API (v3) allows retrieving a list of subscriptions for a channel using the \u003ccode\u003esubscriptions.list\u003c/code\u003e method, either for the authenticated user's channel (using \u003ccode\u003emine=true\u003c/code\u003e) or for another channel (using \u003ccode\u003echannelId\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eTo add a channel subscription, you can use the \u003ccode\u003esubscriptions.insert\u003c/code\u003e method, providing the \u003ccode\u003eyoutube#channel\u003c/code\u003e kind and the target channel's ID in the request body's \u003ccode\u003esnippet.resourceId\u003c/code\u003e property, while also needing to be authorized using OAuth 2.0.\u003c/p\u003e\n"],["\u003cp\u003eDeleting a channel subscription involves first retrieving the subscription list using \u003ccode\u003esubscriptions.list\u003c/code\u003e to find the subscription ID, and then using \u003ccode\u003esubscriptions.delete\u003c/code\u003e with that ID to remove the subscription, which requires OAuth 2.0 authorization.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003esubscriptions.list\u003c/code\u003e method can also be utilized to retrieve a list of channels that subscribe to the currently authenticated user's channel by setting the \u003ccode\u003emySubscribers\u003c/code\u003e parameter to \u003ccode\u003etrue\u003c/code\u003e, while needing to be authorized using OAuth 2.0.\u003c/p\u003e\n"]]],["The YouTube Data API (v3) manages subscriptions via the `subscriptions` resource. To retrieve subscriptions, use `subscriptions.list`, setting `mine` to `true` for the authenticated user or `channelId` for others. Adding subscriptions involves `subscriptions.insert`, specifying `youtube#channel` and the target `channelId`. To delete, use `subscriptions.delete` after using `subscriptions.list` to identify the subscription `id`. Retrieve a list of a channel subscribers by calling `subscriptions.list` and setting the `mySubscribers` to `true`. All actions except by channelId require OAuth 2.0.\n"],null,["The following examples show how to use the YouTube Data API (v3) to perform functions related to subscriptions.\n\nRetrieve a channel's subscriptions \nCall the [subscriptions.list](/youtube/v3/docs/subscriptions/list) method to retrieve subscriptions for a particular channel. There are two ways to identify the channel:\n\n- To retrieve the currently authenticated user's subscriptions, set the [mine](/youtube/v3/docs/subscriptions/list#mine) parameter's value to `true`. Note that a request that uses the `mine` parameter must be authorized using OAuth 2.0.\n\n ```\n https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.subscriptions.list?\n part=snippet,contentDetails\n &mine=true\n ```\n- To retrieve subscriptions for any other channel, set the [channelId](/youtube/v3/docs/subscriptions/list#channelId) parameter's value to that channel's unique YouTube channel ID. The example below retrieves a list of channels subscribed to by the TED channel on YouTube.\n\n ```\n https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.subscriptions.list?\n part=snippet,contentDetails\n &channelId=UCAuUUnT6oDeKwE6v1NGQxug\n ```\n\n **Note:** The API returns a `403 (Forbidden)` HTTP response code if the specified channel does not publicly expose its subscriptions and the request is not authorized by the channel's owner.\n\nSee the [subscriptions.list](/youtube/v3/docs/subscriptions/list#usage) method's documentation for code samples.\n\nAdd a subscription \nCall the [subscriptions.insert](/youtube/v3/docs/subscriptions/insert) method to add a channel subscription. This request must be authorized using OAuth 2.0. The request body is a [subscription](/youtube/v3/docs/subscriptions) resource that sets the following values:\n\n\u003cbr /\u003e\n\n- The [snippet.resourceId.kind](/youtube/v3/docs/subscriptions#snippet.resourceId.kind) contains the value `youtube#channel`.\n- The [snippet.resourceId.channelId](/youtube/v3/docs/subscriptions#snippet.resourceId.channelId) property identifies the channel that is being subscribed to. The property value is a unique YouTube channel ID. The channel ID could be obtained in multiple ways, including calling the [channels.list](/youtube/v3/docs/channels/list) method or retrieving [search results for channels](/youtube/v3/docs/search/list).\n\n\u003cbr /\u003e\n\nThe API request below subscribes you to the TED channel on YouTube: \n\n```\nhttps://developers.google.com/apis-explorer/#p/youtube/v3/youtube.subscriptions.insert?\n part=snippet\n```\n\nThe request body is: \n\n```\n{\n \"snippet\": {\n \"resourceId\": {\n \"kind\": \"youtube#channel\",\n \"videoId\": \"UCAuUUnT6oDeKwE6v1NGQxug\"\n }\n }\n}\n```\n\nSee the [subscriptions.insert](/youtube/v3/docs/subscriptions/insert#usage) method's documentation for code samples.\n\nDelete a subscription \nThis example deletes a subscription. This request must be authorized using OAuth 2.0. This example has two steps:\n\n- **Step 1: Retrieve the subscriptions for the authenticated user's channel**\n\n Call the [subscriptions.list](/youtube/v3/docs/subscriptions/list) method to retrieve the list of subscriptions. The example above for retrieving a channel's subscriptions explains how to make this request.\n\n The application calling the API could process the API response to display a list of subscriptions, using each subscription's ID as a key. In the response, each item's `id` property identifies the subscription ID that uniquely identifies the corresponding subscription. You will use that value to remove an item from the list in the next step.\n- **Step 2: Delete a subscription**\n\n Call the [subscriptions.delete](/youtube/v3/docs/subscriptions/delete) method to delete a subscription. Set the request's [id](/youtube/v3/docs/subscriptions/delete#id) parameter to the subscription ID for the subscription that you want to remove. This request must be authorized using OAuth 2.0.\n\n To complete the request in the APIs Explorer, you need to set the `id` property's value. \n\n ```\n https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.subscriptions.delete?\n id=SUBSCRIPTION_ID\n ```\n\nSee the [subscriptions.delete](/youtube/v3/docs/subscriptions/delete#usage) method's documentation for code samples.\n\nRetrieve a list of subscribers to the authorized user's channel \nTo retrieve a list of channels that subscribe to the currently authenticated user's channel, call the `subscriptions.list` method and set the [mySubscribers](/youtube/v3/docs/subscriptions/list#mySubscribers) parameter's value to `true`. The request must be authorized using OAuth 2.0. \n\n```\nhttps://developers.google.com/apis-explorer/#p/youtube/v3/youtube.subscriptions.list?\n part=snippet,contentDetails\n &mySubscribers=true\n```"]]