ig_get_media
Retrieve Instagram post details including caption, media type, URL, engagement metrics, and timestamp by providing the media ID.
Instructions
Get details of a specific Instagram media post.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| media_id | Yes | Media ID | |
| fields | No | Comma-separated fields (default: id,caption,media_type,media_url,permalink,timestamp,like_count,comments_count) |
Implementation Reference
- src/tools/instagram/media.ts:31-48 (handler)Implementation of the "ig_get_media" tool within the registerIgMediaTools function. It uses the meta client to fetch media details from Instagram.
// ─── ig_get_media ──────────────────────────────────────────── server.tool( "ig_get_media", "Get details of a specific Instagram media post.", { media_id: z.string().describe("Media ID"), fields: z.string().optional().describe("Comma-separated fields (default: id,caption,media_type,media_url,permalink,timestamp,like_count,comments_count)"), }, async ({ media_id, fields }) => { try { const f = fields || "id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,like_count,comments_count"; const { data, rateLimit } = await client.ig("GET", `/${media_id}`, { fields: f }); return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Get media failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );