search_hashtag
Find Instagram hashtag IDs to retrieve related media content. Input a hashtag name to obtain the ID required for accessing posts with that tag.
Instructions
Search for an Instagram hashtag and get its ID. Use the returned ID with get_hashtag_media.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hashtag_name | Yes | Hashtag to search for (with or without #) |
Implementation Reference
- src/client.ts:507-518 (handler)The actual implementation of searchHashtag logic that performs the API request.
async searchHashtag(hashtagName: string): Promise<IGHashtag> { const data = await this.request("GET", "ig_hashtag_search", { params: { q: hashtagName.replace(/^#/, ""), user_id: this.aid(), }, }); const results = data.data ?? []; if (!results.length) throw new InstagramAPIError(`Hashtag '${hashtagName}' not found`); return results[0]; } - src/index.ts:281-291 (registration)Tool registration and schema definition for search_hashtag.
{ name: "search_hashtag", description: "Search for an Instagram hashtag and get its ID. Use the returned ID with get_hashtag_media.", inputSchema: { type: "object" as const, properties: { hashtag_name: { type: "string", description: "Hashtag to search for (with or without #)" }, }, required: ["hashtag_name"], }, - src/index.ts:445-446 (handler)The switch-case handler that invokes searchHashtag from the client.
case "search_hashtag": return JSON.stringify(await c.searchHashtag(args.hashtag_name), null, 2);