get_instagram_posts
Retrieve Instagram posts from a specified user to analyze content, track updates, or gather social media data for research and monitoring purposes.
Instructions
Get Instagram posts from a user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| handle | Yes | Instagram username |
Implementation Reference
- src/index.ts:403-422 (handler)Handler logic for get_instagram_posts tool: extracts handle from args, calls Sociavault API /instagram/posts endpoint, uses extractInstagramPosts helper to process response, returns JSON with posts data.if (name === "get_instagram_posts") { const { handle } = args as { handle: string }; const response = await axios.get(`${BASE_URL}/instagram/posts`, { headers: { "X-API-Key": API_KEY }, params: { handle }, }); const extracted = extractInstagramPosts(response.data, 10); return { content: [ { type: "text", text: JSON.stringify( { handle, posts: extracted, total_returned: extracted.length }, null, 2 ), }, ], }; }
- src/index.ts:256-266 (registration)Tool registration in the tools array: defines name, description, and inputSchema for get_instagram_posts.{ name: "get_instagram_posts", description: "Get Instagram posts from a user", inputSchema: { type: "object", properties: { handle: { type: "string", description: "Instagram username" }, }, required: ["handle"], }, },
- src/index.ts:259-265 (schema)Input schema definition for get_instagram_posts tool: requires 'handle' string parameter.inputSchema: { type: "object", properties: { handle: { type: "string", description: "Instagram username" }, }, required: ["handle"], },
- src/index.ts:38-52 (helper)Helper function to extract and format up to 10 Instagram posts from API response data.function extractInstagramPosts(data: any, limit = 10) { const edges = data?.data?.edges || data?.edges || []; return edges.slice(0, limit).map((edge: any) => { const node = edge.node; return { shortcode: node.shortcode, caption: node.edge_media_to_caption?.edges?.[0]?.node?.text || "", likes: node.edge_liked_by?.count || node.edge_media_preview_like?.count || 0, comments: node.edge_media_to_comment?.count || 0, timestamp: node.taken_at_timestamp, is_video: node.is_video, display_url: node.display_url, }; });