Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

youtube documentation update #8682

Merged
merged 5 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 36 additions & 23 deletions docs/integrations/app-integrations/youtube.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,79 @@ sidebarTitle: YouTube

In this section, we present how to connect YouTube to MindsDB.

[YouTube](https://www.youtube.com/) is a popular online video-sharing platform and social media website where users can upload, view, share, and interact with videos created by individuals and organizations from around the world.
[YouTube](https://www.youtube.com/) is a popular online video-sharing platform and social media website where users
can upload, view, share, and interact with videos created by individuals and organizations from around the world.

Data from YouTube can be utilized within MindsDB to train AI models and chatbots based on user comments, detect sentiment of comments, or use AI models to create replies.
Comment Data from YouTube can be utilized within MindsDB to train AI models and chatbots based on user comments,
detect sentiment of comments, or use AI models to create replies.

## Connection

This handler is implemented using the `google-api-python-client` library, a Python library that from where we can use YouTube v3 API.
First, we have to install the required python packages.
```bash
pip install mindsdb[youtube]
```

<Tip>
If you installed MindsDB from a locally cloned repo via pip, you need to install all handler dependencies manually.
To do so, go to the handler's folder `mindsdb/integrations/handlers/youtube_handler` and run this command: `pip
install -r requirements.txt`.
</Tip>

This handler is implemented using the `google-api-python-client` library, the python library supporting YouTube v3 API.

The only required argument to establish a connection are as follows:

* `youtube_api_token` which is a Google API key used for authentication.

<Tip>
Check out [this guide](https://blog.hubspot.com/website/how-to-get-youtube-api-key) on how to create the API key in order to access YouTube data.
Check out [this guide](https://blog.hubspot.com/website/how-to-get-youtube-api-key) on how to create the API key in
order to access YouTube data.
</Tip>

The first step is to create a database with the new `Youtube` engine using the following command:
The first step is to create a database with the new `youtube` engine using the following command:

```sql
CREATE DATABASE mindsdb_youtube
WITH ENGINE = 'youtube',
PARAMETERS = {
"youtube_api_token": "<your-youtube-api-key-token>"
"youtube_api_token": "<your-youtube-api-key-token>"
};
```

<Tip>
If you installed MindsDB locally via pip, you need to install all handler dependencies manually. To do so, go to the handler's folder (mindsdb/integrations/handlers/youtube_handler) and run this command: `pip install -r requirements.txt`.
</Tip>

## Usage

Use the established connection to query the `get_comments` table for any YouTube Video of your choice.
Use the established connection to query the comments table

```sql
SELECT * FROM mindsdb_youtube.get_comments
WHERE youtube_video_id = "raWFGQ20OfA";
SELECT * FROM mindsdb_youtube.comments
WHERE video_id = "raWFGQ20OfA";
```


Advanced queries which are supported
Advanced queries for the YouTube handler

```sql
SELECT * FROM mindsdb_youtube.get_comments
WHERE youtube_video_id = "raWFGQ20OfA"
SELECT * FROM mindsdb_youtube.comments
WHERE video_id = "raWFGQ20OfA"
ORDER BY display_name ASC
LIMIT 5;
```

Given a channel_id, get information about the channel

Get information about any youtube video using video_id:
```sql
SELECT * FROM mindsdb_youtube.videos
WHERE video_id="id";
SELECT * FROM mindsdb_youtube.channels
WHERE channel_id="UC-...";
```

Here, `channel_id` column is mandatory in the where clause.

Given a channel_id, get information about the channel:
Get information about any YouTube video using video_id:

```sql
SELECT * FROM mindsdb_youtube.channels
WHERE channel_id="UC-...";
SELECT * FROM mindsdb_youtube.videos
WHERE video_id="id";
```

`video_id` is a mandatory column in the where clause.

6 changes: 4 additions & 2 deletions mindsdb/integrations/handlers/youtube_handler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
Youtube handler for MindsDB provides interfaces to connect with Youtube via APIs and pull the video comments of the particular video.

## Youtube
Youtube is app that needs no introduction. It provides a great distribution for all business and creators and It opens-up a great opportunity to do NLP on youtube comments
Youtube is a social video sharing platform businesses and creators. MindsDB users can deploy the youtube integration to perform NLP on youtube comments.

## Youtube Handler Initialization

The Youtube handler is initialized with the following parameters:

- `youtube_api_token`: Youtube API key to use for authentication

Please follow this (link)[https://blog.hubspot.com/website/how-to-get-youtube-api-key] to generate the token for accessing strava API
Please follow this (link)[https://blog.hubspot.com/website/how-to-get-youtube-api-key] to generate the token for
accessing youtube API

## Implemented Features

Expand Down Expand Up @@ -52,6 +53,7 @@ SELECT * FROM mindsdb_youtube.comments
WHERE video_id = "raWFGQ20OfA"
ORDER BY display_name ASC
LIMIT 5;
~~~~

Given a channel_id, get information about the channel

Expand Down
Loading