We are updating the Data API to match how YouTube counts views for Shorts.
Learn more
YouTube Data API (v3) Code Samples
Stay organized with collections
Save and categorize content based on your preferences.
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.
Ruby
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-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\u003eExplore the use cases and code samples page to find examples for the YouTube Data API and YouTube Live Streaming API.\u003c/p\u003e\n"],["\u003cp\u003eThe use cases and code samples page provides interactive samples in Java, JavaScript, PHP, and Python, allowing you to adjust parameters and see updated code.\u003c/p\u003e\n"],["\u003cp\u003eStandalone code snippets are available for Apps Script, Go, .NET, and Ruby, demonstrating common methods like uploading videos, searching for videos, and managing playlists.\u003c/p\u003e\n"],["\u003cp\u003eThe 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.\u003c/p\u003e\n"],["\u003cp\u003eCode samples are provided for various common tasks such as authorization, uploading, and searching for videos, as well as creating playlists and subscriptions.\u003c/p\u003e\n"]]],["The document details code samples for the YouTube Data API and YouTube Live Streaming API. Users can find examples for common use cases by selecting an API resource and method. The APIs Explorer widget allows interaction with samples, including parameter adjustments, with working code in Java, JavaScript, PHP, and Python. Additional code snippets are available in Apps Script, Go, .NET, and Ruby, covering actions like subscribing to channels, retrieving uploads, searching videos, updating videos, and creating playlists.\n"],null,["You can explore common use cases for the YouTube Data API and YouTube Live Streaming API on the [use cases and code samples](/youtube/v3/code_samples/code_snippets) page.\n\nThe 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.\n\nThe following section lists code samples available in other languages.\n\nStandalone code snippets\n\nThe 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](/youtube/v3/code_samples/code_snippets) page. \n\nApps Script\n\n| Code sample | Methods |\n|--------------------------------------------------------------------------------------------------|---------------------------------------------------------------|\n| [Add a channel subscription](/youtube/v3/code_samples/apps-script#subscribe_to_channel) | [subscriptions.insert](/youtube/v3/docs/subscriptions/insert) |\n| [Retrieve current user's uploads](/youtube/v3/code_samples/apps-script#retrieve_my_uploads) | [channels.list](/youtube/v3/docs/channels/list) |\n| [Search for videos related to a keyword](/youtube/v3/code_samples/apps-script#search_by_keyword) | [search.list](/youtube/v3/docs/search/list) |\n| [Update a video](/youtube/v3/code_samples/apps-script#update_video) | [videos.update](/youtube/v3/docs/videos/update) |\n\nGo\n\n| Code sample | Methods |\n|-----------------------------------------------------------------------------------------|-----------------------------------------------------------|\n| [Authorize a request](/youtube/v3/code_samples/go#authorize_a_request) | Any method requiring authorization |\n| [Retrieve current user's uploads](/youtube/v3/code_samples/go#retrieve_my_uploads) | [playlistItems.list](/youtube/v3/docs/playlistItems/list) |\n| [Search for videos related to a keyword](/youtube/v3/code_samples/go#search_by_keyword) | [search.list](/youtube/v3/docs/search/list) |\n| [Upload a video](/youtube/v3/code_samples/go#upload_a_video) | [videos.insert](/youtube/v3/docs/videos/insert) |\n\n.NET\n\n| Code sample | Methods |\n|------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|\n| [Create a playlist](/youtube/v3/code_samples/dotnet#create_a_playlist) | [playlists.insert](/youtube/v3/docs/playlists/insert) |\n| [Retrieve current user's uploaded videos](/youtube/v3/code_samples/dotnet#retrieve_my_uploads) | [channels.list](/youtube/v3/docs/channels/list) [playlistItems.list](/youtube/v3/docs/playlistItems/list) |\n| [Search for videos related to a keyword](/youtube/v3/code_samples/dotnet#search_by_keyword) | [search.list](/youtube/v3/docs/search/list) |\n| [Upload a video](/youtube/v3/code_samples/dotnet#upload_a_video) | [videos.insert](/youtube/v3/docs/videos/insert) |\n\nRuby\n\n| Code sample | Methods |\n|-------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|\n| [Authorize a request](/youtube/v3/code_samples/ruby#authorize_a_request) | Any method requiring authorization |\n| [Create a channel subscription](/youtube/v3/code_samples/ruby#add_a_channel_subscription) | [subscriptions.insert](/youtube/v3/docs/subscriptions/insert) |\n| [Retrieve current user's uploads](/youtube/v3/code_samples/ruby#retrieve_my_uploads) | [channels.list](/youtube/v3/docs/channels/list) [playlistItems.list](/youtube/v3/docs/playlistItems/list) |\n| [Search for videos related to a keyword](/youtube/v3/code_samples/ruby#search_by_keyword) | [search.list](/youtube/v3/docs/search/list) |\n| [Upload a video](/youtube/v3/code_samples/ruby#upload_a_video) | [videos.insert](/youtube/v3/docs/videos/insert) |\n\nYou may also be able to adapt one of the other\n[Ruby samples](https://github.com/googleapis/google-api-ruby-client/tree/main/samples)."]]