The youtube-data-api.gs
file in this directory contains code snippets that are generated
by the Data API code snippet tool at:
https://developers.google.com/youtube/v3/code_samples/code_snippets
You can use that tool to test different parameter values and to generate code samples with those modified parameter values. The tool generates code for several other programming languages as well.
Each function in the file demonstrates a particular use case for a particular API method.
For example, there are several different use cases for calling the search.list()
method,
such as searching by keyword or searching for live events.
In addition to the use-case-specific functions, the file also contains some boilerplate code that prints some data from an API response to the logging console. The print function is currently designed just to show that each API response returns data and serves as a placeholder for any function that would actually process an API response.
To run these samples:
- Create a spreadsheet in Google Drive.
- Select Tools > Script Editor from the menu bar.
- Paste this code into the script editor and save your file.
- In the script, select Resources > Advanced Google Services and toggle the option for the YouTube Data API to on.
- Click the link to the Google Developers Console and enable the YouTube Data API for the project.
- Go back to the script editor and click 'OK' to indicate that you have finished enabling advanced services.
- Run the
Main
function in your script. - Select View > Logs to see the output from the script.