> For the complete documentation index, see [llms.txt](https://whitepaper.aitech.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whitepaper.aitech.io/agentforge/tools/youtube.md).

# youtube

[YouTube](https://www.youtube.com/) is the world's largest video-sharing platform, hosting billions of videos across countless topics and serving over 2 billion logged-in monthly users.

With YouTube’s Data API, you can:

* **Search for videos**: Find relevant content using keywords, categories, and filters.
* **Access detailed metadata**: Retrieve information such as titles, descriptions, view counts, and engagement stats.
* **Monitor trends**: Identify what’s trending in a region or topic.
* **Analyze creators**: Track uploads, performance, and audience engagement.

In Agent Forge, the YouTube block allows your agents to search for and analyze YouTube content programmatically. It’s ideal for automations like research, content curation, or data enrichment pipelines that require access to live video information.

## Setup (one-time)

To use the YouTube block, you need a **YouTube Data API v3 key** from Google Cloud. Follow these steps:

1. Go to the Google Cloud Console → <https://console.cloud.google.com/>
2. Click **“Select a Project” → New Project** and give it a name.
3. After creation, go to **APIs & Services → Library**.
4. Search for **“YouTube Data API v3”** and click **Enable**.
5. Navigate to **APIs & Services → Credentials**.
6. Click **“Create Credentials” → “API Key”**.
7. Copy the generated **API key** and use it in your block’s `apiKey` field.

{% hint style="warning" %}
**Important:** Keep your API key private. Avoid committing it to public repositories or sharing it in plaintext.
{% endhint %}

## Usage Instructions

This block searches for YouTube videos using Google’s **YouTube Data API v3**.\
Your agents can programmatically perform searches, filter results, and analyze the metadata of videos returned by the API.

Typical use cases:

* Discover educational or tutorial videos automatically.
* Retrieve video titles, URLs, and statistics for dashboards.
* Research trending topics across regions.

## Tools

### `youtube_search`

Search for videos on YouTube using the YouTube Data API.

#### Input

| Parameter    | Type   | Required | Description                                              |
| ------------ | ------ | -------- | -------------------------------------------------------- |
| `query`      | string | Yes      | The search query (e.g., "AI tutorials")                  |
| `maxResults` | number | No       | Maximum number of videos to return (default: 5, max: 50) |
| `apiKey`     | string | Yes      | Your YouTube Data API v3 key                             |

#### Output

| Parameter      | Type   | Description                                                                                 |
| -------------- | ------ | ------------------------------------------------------------------------------------------- |
| `items`        | json   | Array of search result objects including title, description, video ID, and snippet metadata |
| `totalResults` | number | Total number of matching results                                                            |

## Notes

* Category: `tools`
* Type: `youtube`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://whitepaper.aitech.io/agentforge/tools/youtube.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
