get_hashtag_media
Retrieve top or recent Instagram posts for a hashtag using its ID from search_hashtag, supporting up to 50 posts per request.
Instructions
Get top or recent media for a hashtag. Use search_hashtag first to get the hashtag ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hashtag_id | Yes | Hashtag ID from search_hashtag | |
| media_type | No | Get top or recent media | top |
| limit | No | Number of posts (max 50) |
Implementation Reference
- src/client.ts:520-540 (handler)Implementation of the getHashtagMedia method which calls the Instagram API.
async getHashtagMedia( hashtagId: string, mediaType: "top" | "recent" = "top", limit = 25 ): Promise<IGMedia[]> { const fields = "id,media_type,media_url,permalink,caption,timestamp,like_count,comments_count"; const data = await this.request( "GET", `${hashtagId}/${mediaType}_media`, { params: { user_id: this.aid(), fields, limit: String(Math.min(limit, 50)), }, } ); return data.data ?? []; } - src/index.ts:294-305 (schema)Tool definition and input schema for get_hashtag_media.
name: "get_hashtag_media", description: "Get top or recent media for a hashtag. Use search_hashtag first to get the hashtag ID.", inputSchema: { type: "object" as const, properties: { hashtag_id: { type: "string", description: "Hashtag ID from search_hashtag" }, media_type: { type: "string", enum: ["top", "recent"], description: "Get top or recent media", default: "top" }, limit: { type: "integer", description: "Number of posts (max 50)", minimum: 1, maximum: 50, default: 25 }, }, required: ["hashtag_id"], }, - src/index.ts:448-451 (registration)Handler logic routing for get_hashtag_media.
case "get_hashtag_media": { const media = await c.getHashtagMedia(args.hashtag_id, args.media_type ?? "top", args.limit ?? 25); return JSON.stringify({ hashtag_id: args.hashtag_id, media, count: media.length }, null, 2); }