instagram▌
vm0-ai/vm0-skills · updated Apr 8, 2026
Use the Instagram Graph API by directly executing curl commands to read and publish Instagram content.
Instagram API (Graph API)
Use the Instagram Graph API by directly executing curl commands to read and publish Instagram content.
Official docs:
https://developers.facebook.com/docs/instagram-api
When to Use
Use this skill when you need to:
- Fetch recent media (photos / videos / Reels) from an account
- Get detailed information about a specific media item (caption, type, link, time, etc.)
- Search recent media by hashtag
- Publish image posts via API (with caption)
Prerequisites
- You must have an Instagram Business / Creator account linked to a Facebook Page
- Create an app in Facebook Developers and enable Instagram Basic Display / Instagram Graph API permissions
- Obtain:
INSTAGRAM_TOKEN: a long-lived user access tokenINSTAGRAM_BUSINESS_ACCOUNT_ID: your Instagram Business account ID
Set the environment variables, for example:
export INSTAGRAM_TOKEN="EAAG..."
export INSTAGRAM_BUSINESS_ACCOUNT_ID="1784140xxxxxxx"
These examples use Graph API version v21.0. You can replace this with the latest version if needed.
Required permissions (scopes)
Depending on which endpoints you use, make sure your app has requested and been approved for (at least):
instagram_basicpages_show_listinstagram_content_publish(for publishing media)instagram_manage_insightsand related permissions (for insights / some hashtag use cases)
How to Use
All examples below assume you have already set:
INSTAGRAM_TOKEN
INSTAGRAM_BUSINESS_ACCOUNT_ID
1. Fetch recent media for the account
Fetch the most recent media (photos / videos / Reels) for the account:
curl -s -X GET "https://graph.facebook.com/v21.0/$INSTAGRAM_BUSINESS_ACCOUNT_ID/media?fields=id,caption,media_type,media_url,permalink,timestamp" --header "Authorization: Bearer $INSTAGRAM_TOKEN"
Notes:
- Each item in the returned JSON represents a media object
- Common fields:
id: media ID (used for details / insights later)caption: caption textmedia_type:IMAGE/VIDEO/CAROUSEL_ALBUMmedia_url: direct URL to the mediapermalink: Instagram permalinktimestamp: creation time
2. Get details for a single media
If you already have a media id, you can fetch more complete information. Replace <your-media-id> with the id field from the "Get User Media" response (section 1 above):
curl -s -X GET "https://graph.facebook.com/v21.0/<your-media-id>?fields=id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,username" --header "Authorization: Bearer $INSTAGRAM_TOKEN"
3. Search media by hashtag
Note: hashtag search requires proper business use cases and permissions as defined by Facebook/Instagram. Refer to the official docs.
This usually involves two steps:
3.1 Get the hashtag ID
Replace <hashtag-name> with any hashtag name you want to search for (without the # symbol), e.g., "travel", "food", "photography":
curl -s -X GET "https://graph.facebook.com/v21.0/ig_hashtag_search?user_id=$INSTAGRAM_BUSINESS_ACCOUNT_ID&q=<hashtag-name>" --header "Authorization: Bearer $INSTAGRAM_TOKEN"
Note the id field in the returned JSON for use in the next step.
3.2 Fetch recent media for the hashtag
Replace <hashtag-id> with the id field from the "Search Hashtag" response (section 3.1 above):
curl -s -X GET "https://graph.facebook.com/v21.0/<hashtag-id>/recent_media?user_id=$INSTAGRAM_BUSINESS_ACCOUNT_ID&fields=id,caption,media_type,media_url,permalink,timestamp" --header "Authorization: Bearer $INSTAGRAM_TOKEN"
4. Publish an image post
Publishing an image post via the Graph API usually requires two steps:
- Create a media container
- Publish the container to the feed
4.1 Create a media container
Write the request data to /tmp/request.json:
{
"image_url": "https://example.com/image.jpg",
"caption": "Hello from Instagram API 👋"
}
Replace https://example.com/image.jpg with any publicly accessible image URL and update the caption text as needed.
curl -s -X POST "https://graph.facebook.com/v21.0/$INSTAGRAM_BUSINESS_ACCOUNT_ID/media" -H "Content-Type: application/json" -d @/tmp/request.json --header "Authorization: Bearer $INSTAGRAM_TOKEN"
The response will contain an id (media container ID), for example:
{
"id": "1790xxxxxxxxxxxx"
}
Note this ID for use in the next step.
4.2 Publish the media container to the feed
Write the request data to /tmp/request.json:
{
"creation_id": "<your-creation-id>"
}
Replace <your-creation-id> with the id field from the "Create Media Container" response (section 4.1 above):
curl -s -X POST "https://graph.facebook.com/v21.0/$INSTAGRAM_BUSINESS_ACCOUNT_ID/media_publish" -H "Content-Type: application/json" -d @/tmp/request.json --header "Authorization: Bearer $INSTAGRAM_TOKEN"
If successful, the response will contain the final media id:
{
"id": "1791yyyyyyyyyyyy"
}
You can then use the "Get details for a single media" command to fetch its permalink.
5. Common errors and troubleshooting
- Permissions / OAuth errors
- Typical error message:
(#10) Application does not have permission for this action - Check:
- Whether the app has been reviewed / approved
- Whether the required Instagram permissions are enabled
- Whether
INSTAGRAM_TOKENis a valid long-lived token
- Unsupported account type
- Most Graph API features require Business / Creator accounts
- Make sure the Instagram account type is correct and linked to a Facebook Page
- Rate limits
- Too many requests in a short period may hit rate limits; add delays for bulk operations
Guidelines
- Do not log tokens:
INSTAGRAM_TOKENis sensitive; avoid printing it in logs or chat transcripts - Validate curl commands in a test environment first: confirm flows before wiring them into automation / agents
- Keep API version up to date: periodically check Facebook docs and update the
v21.0version in URLs to the latest - Use placeholder text for IDs: all examples use placeholder text like
<your-media-id>instead of shell variables in URLs to avoid dependencies and make examples self-contained
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.8★★★★★41 reviews- ★★★★★Soo Brown· Dec 28, 2024
instagram fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Chaitanya Patil· Dec 16, 2024
instagram has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Advait Jain· Dec 16, 2024
We added instagram from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Amelia Mensah· Dec 8, 2024
instagram reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Amelia Torres· Nov 19, 2024
I recommend instagram for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Ama Li· Nov 19, 2024
Registry listing for instagram matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Piyush G· Nov 7, 2024
Solid pick for teams standardizing on skills: instagram is focused, and the summary matches what you get after install.
- ★★★★★Daniel Jain· Nov 7, 2024
Useful defaults in instagram — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Shikha Mishra· Oct 26, 2024
We added instagram from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Kwame Khan· Oct 26, 2024
instagram has been reliable in day-to-day use. Documentation quality is above average for community skills.
showing 1-10 of 41