get_tiktok_videos
Retrieve TikTok videos from any user profile by providing their username. Access video content and data through the SociaVault social media API integration.
Instructions
Get TikTok videos from a user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| handle | Yes | TikTok username |
Implementation Reference
- src/index.ts:424-443 (handler)Handler logic for the get_tiktok_videos tool: extracts handle from arguments, makes API request to /tiktok/videos endpoint using axios, processes response with extractTikTokVideos helper, and returns formatted JSON response.if (name === "get_tiktok_videos") { const { handle } = args as { handle: string }; const response = await axios.get(`${BASE_URL}/tiktok/videos`, { headers: { "X-API-Key": API_KEY }, params: { handle }, }); const extracted = extractTikTokVideos(response.data, 10); return { content: [ { type: "text", text: JSON.stringify( { handle, videos: extracted, total_returned: extracted.length }, null, 2 ), }, ], }; }
- src/index.ts:267-277 (registration)Tool registration in the tools array, including name, description, and input schema.{ name: "get_tiktok_videos", description: "Get TikTok videos from a user", inputSchema: { type: "object", properties: { handle: { type: "string", description: "TikTok username" }, }, required: ["handle"], }, },
- src/index.ts:270-276 (schema)Input schema definition for the get_tiktok_videos tool, specifying the required 'handle' parameter.inputSchema: { type: "object", properties: { handle: { type: "string", description: "TikTok username" }, }, required: ["handle"], },
- src/index.ts:99-120 (helper)Helper function to parse and extract relevant TikTok video data from the API response, limiting to 10 videos.function extractTikTokVideos(data: any, limit = 10) { const videos = data?.data?.itemList || data?.itemList || data?.data?.videos || data?.videos || []; return videos.slice(0, limit).map((video: any) => { const stats = video.statistics || video.stats || {}; return { id: video.id || video.aweme_id, description: video.desc || video.description || "", likes: stats.like_count || stats.digg_count || 0, comments: stats.comment_count || 0, shares: stats.share_count || 0, views: stats.play_count || stats.view_count || 0, timestamp: video.create_time || video.timestamp, duration: video.duration, cover: video.cover || video.video?.cover || video.cover_url, }; }); }