ig_get_hashtag
Retrieve complete hashtag details, metrics, and metadata using the hashtag ID from a search result.
Instructions
Get hashtag information by ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hashtag_id | Yes | Hashtag ID (from ig_search_hashtag) |
Implementation Reference
- src/tools/instagram/hashtags.ts:27-43 (handler)The handler function for the 'ig_get_hashtag' tool. It takes a 'hashtag_id' string parameter, makes a GET request to the Meta Graph API via client.ig() with fields 'id,name,media_count', and returns the hashtag info as JSON text.
server.tool( "ig_get_hashtag", "Get hashtag information by ID.", { hashtag_id: z.string().describe("Hashtag ID (from ig_search_hashtag)"), }, async ({ hashtag_id }) => { try { const { data, rateLimit } = await client.ig("GET", `/${hashtag_id}`, { fields: "id,name,media_count", }); return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Get hashtag failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - Zod schema for the input parameter 'hashtag_id' (a required string describing 'Hashtag ID (from ig_search_hashtag)').
{ hashtag_id: z.string().describe("Hashtag ID (from ig_search_hashtag)"), - src/tools/instagram/hashtags.ts:27-43 (registration)The tool is registered via server.tool() call with name 'ig_get_hashtag' and description 'Get hashtag information by ID.'
server.tool( "ig_get_hashtag", "Get hashtag information by ID.", { hashtag_id: z.string().describe("Hashtag ID (from ig_search_hashtag)"), }, async ({ hashtag_id }) => { try { const { data, rateLimit } = await client.ig("GET", `/${hashtag_id}`, { fields: "id,name,media_count", }); return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Get hashtag failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/index.ts:46-46 (registration)The registration function 'registerIgHashtagTools' is called to register all hashtag tools including 'ig_get_hashtag'.
registerIgHashtagTools(server, client); - src/index.ts:16-16 (registration)The import statement that brings in 'registerIgHashtagTools' from the hashtags.ts module.
import { registerIgHashtagTools } from "./tools/instagram/hashtags.js";