# YouTube Data API

The connector calls the [YouTube Data API](https://developers.google.com/youtube/v3/docs/).

***Note:** This connector is not designed for analytics and reporting. Use the
[YouTube Reporting](https://help.keboola.com/components/extractors/social/youtube-reporting/) or the [Google Analytics](https://help.keboola.com/components/extractors/marketing-sales/google-analytics/) data source connectors for such purposes.*

## Configuration
To begin, [create a new configuration](https://help.keboola.com/components/configurations/#create-a-configuration) for the **YouTube** connector.
Then click **Authorize Account** to [authorize the configuration](https://help.keboola.com/components/authorization/). 

Select one of the two available **templates**: 

- Channels: Provides information about your channels.
- Videos: Offers details about your playlists and their associated videos. 

![Screenshot - Create configuration](https://help.keboola.com/components/extractors/social/youtube/youtube-1.png)

You can [switch to the JSON editor](https://help.keboola.com/components/extractors/generic-extractor/#template-mode) for more advanced configurations.

### Advanced Configuration
To give a simple example, the configuration for details about your channel looks like this:

```json
{
  "jobs": [
    {
      "endpoint": "channels?mine=true&part=snippet,contentDetails,statistics",
      "dataType": "channels",
      "dataField": "items"
    }
  ]
}
```

To learn what is the correct endpoint, look to YouTube's [API documentation](https://developers.google.com/youtube/v3/docs/) and browse for, e.g., *Channels: list*. 
Choose one of the predefined use cases, for instance, *list (my channel)*, and switch the example to CURL. 
The endpoint is under `# HTTP URL:`, where you omit the base URL `https://www.googleapis.com/youtube/v3/`.

![Screenshot - YouTube API](https://help.keboola.com/components/extractors/social/youtube/api_sample.png)

You can use other [Generic Extractor's](https://help.keboola.com/components/extractors/generic-extractor/) functionality, too, including nesting. This example downloads your channel, iterates through its playlists, and gets all their videos:

```json
{
  "jobs": [
    {
      "endpoint": "channels?mine=true&part=id,snippet",
      "dataType": "channels",
      "dataField": "items",
      "children": [
        {
          "endpoint": "playlists?channelId={channelId}&part=id,snippet",
          "dataType": "playlists",
          "dataField": "items",
          "placeholders": {
            "channelId": "id"
          },
          "children": [
            {
              "endpoint": "playlistItems?playlistId={playlistId}&part=id,snippet",
              "dataType": "videos",
              "dataField": "items",
              "placeholders": {
                "playlistId": "id"
              }
            }
          ]
        }
      ]
    }
  ]
}
```
