Skip to main content
Glama

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
NameRequiredDescriptionDefault
media_idYesMedia ID
fieldsNoComma-separated fields (default: id,caption,media_type,media_url,permalink,timestamp,like_count,comments_count)

Implementation Reference

  • 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 };
        }
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mikusnuz/meta-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server