get_youtube_channel
Retrieve YouTube channel information including profile details, content data, and engagement metrics using a channel handle or @username.
Instructions
Get YouTube channel data
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| handle | Yes | YouTube channel handle or @username |
Input Schema (JSON Schema)
{
"properties": {
"handle": {
"description": "YouTube channel handle or @username",
"type": "string"
}
},
"required": [
"handle"
],
"type": "object"
}
Implementation Reference
- src/index.ts:487-497 (handler)Handler for the get_youtube_channel tool: extracts 'handle' argument, makes API request to Sociavault /youtube/channel endpoint, processes response with extractYouTubeChannel helper, and returns JSON-formatted channel data.if (name === "get_youtube_channel") { const { handle } = args as { handle: string }; const response = await axios.get(`${BASE_URL}/youtube/channel`, { headers: { "X-API-Key": API_KEY }, params: { handle }, }); const extracted = extractYouTubeChannel(response.data); return { content: [{ type: "text", text: JSON.stringify(extracted, null, 2) }], }; }
- src/index.ts:300-312 (registration)Registration of the get_youtube_channel tool in the tools list, including name, description, and input schema defining the required 'handle' parameter.{ name: "get_youtube_channel", description: "Get YouTube channel data", inputSchema: { type: "object", properties: { handle: { type: "string", description: "YouTube channel handle or @username", }, }, required: ["handle"], },
- src/index.ts:153-170 (helper)Helper function that parses the YouTube channel API response data, extracting key fields such as title, description, subscriber count, video count, view count, thumbnail, and publish date.function extractYouTubeChannel(data: any) { const channel = data?.data?.channel || data?.channel || data?.data || {}; const snippet = channel.snippet || {}; const statistics = channel.statistics || {}; return { title: snippet.title || channel.title, description: snippet.description || channel.description || "", subscribers: parseInt(statistics.subscriberCount || statistics.subscribers || "0") || 0, videos: parseInt(statistics.videoCount || "0") || 0, views: parseInt(statistics.viewCount || "0") || 0, custom_url: channel.customUrl || snippet.customUrl, thumbnail: snippet.thumbnails?.high?.url || snippet.thumbnails?.default?.url, published_at: snippet.publishedAt || channel.publishedAt, }; }