YouTube Data API (v3) Code Samples

  • Explore the use cases and code samples page to find examples for the YouTube Data API and YouTube Live Streaming API.

  • The use cases and code samples page provides interactive samples in Java, JavaScript, PHP, and Python, allowing you to adjust parameters and see updated code.

  • Standalone code snippets are available for Apps Script, Go, .NET, and Ruby, demonstrating common methods like uploading videos, searching for videos, and managing playlists.

  • The page provides code samples for several common methods including subscriptions.insert, channels.list, search.list, and videos.update, allowing developers to find quick snippets for their use cases.

  • Code samples are provided for various common tasks such as authorization, uploading, and searching for videos, as well as creating playlists and subscriptions.

You can explore common use cases for the YouTube Data API and YouTube Live Streaming API on the use cases and code samples page.

The page lets you select an API resource and method and then lists common use cases for that method. You can then click on any use case to populate the APIs Explorer widget with sample parameter and property values for that use case. You can also open the fullscreen APIs Explorer widget to see working code samples for Java, JavaScript, PHP, and Python. If you update parameter or property values in the APIs Explorer, the code samples also update to reflect your changes.

The following section lists code samples available in other languages.

Standalone code snippets

The lists below identify code samples available for the YouTube Data API (v3) in languages other than Java, JavaScript, PHP, and Python. As noted in the previous section, code samples for those languages are available on the use cases and code samples page.

Apps Script

Code sample Methods
Add a channel subscription subscriptions.insert
Retrieve current user's uploads channels.list
Search for videos related to a keyword search.list
Update a video videos.update

Go

Code sample Methods
Authorize a request Any method requiring authorization
Retrieve current user's uploads playlistItems.list
Search for videos related to a keyword search.list
Upload a video videos.insert

.NET

Code sample Methods
Create a playlist playlists.insert
Retrieve current user's uploaded videos channels.list
playlistItems.list
Search for videos related to a keyword search.list
Upload a video videos.insert

Ruby

Code sample Methods
Authorize a request Any method requiring authorization
Create a channel subscription subscriptions.insert
Retrieve current user's uploads channels.list
playlistItems.list
Search for videos related to a keyword search.list
Upload a video videos.insert

You may also be able to adapt one of the other Ruby samples.

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年09月26日 UTC.