|
| 1 | +# Apps Script Code Snippets |
| 2 | + |
| 3 | +The `youtube-data-api.gs` file in this directory contains code snippets that are generated |
| 4 | +by the Data API code snippet tool at: |
| 5 | +https://developers.google.com/youtube/v3/code_samples/code_snippets |
| 6 | + |
| 7 | +You can use that tool to test different parameter values and to generate code samples with |
| 8 | +those modified parameter values. The tool generates code for several other programming |
| 9 | +languages as well. |
| 10 | + |
| 11 | +Each function in the file demonstrates a particular use case for a particular API method. |
| 12 | +For example, there are several different use cases for calling the `search.list()` method, |
| 13 | +such as searching by keyword or searching for live events. |
| 14 | + |
| 15 | +In addition to the use-case-specific functions, the file also contains some boilerplate code |
| 16 | +that prints some data from an API response to the logging console. The print function is |
| 17 | +currently designed just to show that each API response returns data and serves as a placeholder |
| 18 | +for any function that would actually process an API response. |
| 19 | + |
| 20 | +## Running these samples |
| 21 | + |
| 22 | +To run these samples: |
| 23 | + |
| 24 | +1. Create a spreadsheet in [Google Drive](https://spreadsheets.google.com). |
| 25 | +2. Select **Tools > Script Editor** from the menu bar. |
| 26 | +3. Paste this code into the script editor and save your file. |
| 27 | +4. In the script, select **Resources > Advanced Google Services** and toggle the option for the |
| 28 | + YouTube Data API to on. |
| 29 | +5. Click the link to the Google Developers Console and enable the YouTube Data API for the project. |
| 30 | +6. Go back to the script editor and click 'OK' to indicate that you have finished enabling advanced services. |
| 31 | +7. Run the `Main` function in your script. |
| 32 | +8. Select **View > Logs** to see the output from the script. |
0 commit comments