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