Python Code Samples

Stay organized with collections Save and categorize content based on your preferences.

Python code samples for the YouTube Data API are now available in the APIs Explorer. See the use cases page to select an API method and see its use cases. On that page, you can automatically populate the APIs Explorer widget with sample parameter and property values for any use case and open the fullscreen APIs Explorer to see code samples for Python and several other languages.

If you modify parameter or property values in the APIs Explorer or if you change the scopes selected for any particular method, the code samples automatically update to reflect your changes.

You can find the same use cases and samples in the documentation for specific API methods, such as channels.list or videos.insert.

All Python code samples use the Google APIs Client Library for Python. You can find instructions for running the code samples on your local machine in the APIs Explorer guide for code samples.