KosmoKrator

productivity

Instagram CLI for AI Agents

Use the Instagram CLI from KosmoKrator to call Instagram tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

Instagram CLI Setup

Instagram can be configured headlessly with `kosmokrator integrations:configure instagram`.

Install, configure, and verify
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure instagram --set access_token="$INSTAGRAM_ACCESS_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor instagram --json
kosmokrator integrations:status --json

Credentials

Authentication type: Manual OAuth token oauth2_manual_token. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.

KeyEnv varTypeRequiredLabel
access_token INSTAGRAM_ACCESS_TOKEN Secret secret yes Access Token
url INSTAGRAM_URL URL url no API Base URL

Command Patterns

The generic command is stable across every integration. The provider shortcut is shorter for humans.

Generic CLI call
kosmo integrations:call instagram.instagram_list_media '{"limit":1,"after":"example_after","before":"example_before","fields":"example_fields"}' --json
Provider shortcut
kosmo integrations:instagram instagram_list_media '{"limit":1,"after":"example_after","before":"example_before","fields":"example_fields"}' --json

Discovery

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

Discovery commands
kosmo integrations:docs instagram --json
kosmo integrations:docs instagram.instagram_list_media --json
kosmo integrations:schema instagram.instagram_list_media --json
kosmo integrations:search "Instagram" --json
kosmo integrations:list --json

Automation Contexts

The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.

CLI Functions

Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.

instagram.instagram_list_media

List media published by the authenticated Instagram user. Returns media IDs, captions, types, URLs, and timestamps. Supports cursor-based pagination.

Read read
Parameters
limit, after, before, fields
Generic call
kosmo integrations:call instagram.instagram_list_media '{"limit":1,"after":"example_after","before":"example_before","fields":"example_fields"}' --json
Shortcut
kosmo integrations:instagram instagram_list_media '{"limit":1,"after":"example_after","before":"example_before","fields":"example_fields"}' --json

instagram.instagram_get_media

Get details of a specific Instagram media item by its ID. Returns caption, media type, URL, timestamp, like count, and comment count.

Read read
Parameters
mediaId, fields
Generic call
kosmo integrations:call instagram.instagram_get_media '{"mediaId":"example_mediaId","fields":"example_fields"}' --json
Shortcut
kosmo integrations:instagram instagram_get_media '{"mediaId":"example_mediaId","fields":"example_fields"}' --json

instagram.instagram_create_media

Publish a new media item (photo or video) to Instagram. Provide the media URL and an optional caption. The media is published immediately unless publish is set to false.

Write write
Parameters
imageUrl, caption, mediaType, publish
Generic call
kosmo integrations:call instagram.instagram_create_media '{"imageUrl":"example_imageUrl","caption":"example_caption","mediaType":"example_mediaType","publish":true}' --json
Shortcut
kosmo integrations:instagram instagram_create_media '{"imageUrl":"example_imageUrl","caption":"example_caption","mediaType":"example_mediaType","publish":true}' --json

instagram.instagram_list_comments

List comments on a specific Instagram media item. Returns comment IDs, text, timestamps, usernames, and like counts. Supports pagination.

Read read
Parameters
mediaId, limit, after
Generic call
kosmo integrations:call instagram.instagram_list_comments '{"mediaId":"example_mediaId","limit":1,"after":"example_after"}' --json
Shortcut
kosmo integrations:instagram instagram_list_comments '{"mediaId":"example_mediaId","limit":1,"after":"example_after"}' --json

instagram.instagram_get_comment

Get details of a specific Instagram comment by its ID. Returns the comment text, timestamp, username, and like count.

Read read
Parameters
commentId
Generic call
kosmo integrations:call instagram.instagram_get_comment '{"commentId":"example_commentId"}' --json
Shortcut
kosmo integrations:instagram instagram_get_comment '{"commentId":"example_commentId"}' --json

instagram.instagram_list_insights

Get account-level insights and performance metrics for the authenticated Instagram user. Supports metrics like impressions, reach, follower count, and profile views with configurable time periods.

Read read
Parameters
metric, period, since, until
Generic call
kosmo integrations:call instagram.instagram_list_insights '{"metric":"example_metric","period":"example_period","since":"example_since","until":"example_until"}' --json
Shortcut
kosmo integrations:instagram instagram_list_insights '{"metric":"example_metric","period":"example_period","since":"example_since","until":"example_until"}' --json

instagram.instagram_get_current_user

Get the currently authenticated Instagram user profile. Returns user ID, username, name, account type, media count, and follower/following counts.

Read read
Parameters
none
Generic call
kosmo integrations:call instagram.instagram_get_current_user '{}' --json
Shortcut
kosmo integrations:instagram instagram_get_current_user '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

instagram.instagram_list_media 4 parameters
Schema command
kosmo integrations:schema instagram.instagram_list_media --json
ParameterTypeRequiredDescription
limit integer no Number of media items to return per page.
after string no Pagination cursor — return items after this cursor.
before string no Pagination cursor — return items before this cursor.
fields string no Comma-separated list of fields to return (e.g. "id,caption,media_type,media_url,permalink,timestamp,username").
instagram.instagram_get_media 2 parameters
Schema command
kosmo integrations:schema instagram.instagram_get_media --json
ParameterTypeRequiredDescription
mediaId string yes The media ID to retrieve.
fields string no Comma-separated list of fields to return.
instagram.instagram_create_media 4 parameters
Schema command
kosmo integrations:schema instagram.instagram_create_media --json
ParameterTypeRequiredDescription
imageUrl string yes URL of the image or video to publish.
caption string no Caption text for the media post.
mediaType string no Type of media: "IMAGE", "VIDEO", or "CAROUSEL". Defaults to "IMAGE".
publish boolean no Whether to publish immediately (default true). Set to false to create a container only.
instagram.instagram_list_comments 3 parameters
Schema command
kosmo integrations:schema instagram.instagram_list_comments --json
ParameterTypeRequiredDescription
mediaId string yes The media ID to list comments for.
limit integer no Number of comments to return per page.
after string no Pagination cursor — return comments after this cursor.
instagram.instagram_get_comment 1 parameters
Schema command
kosmo integrations:schema instagram.instagram_get_comment --json
ParameterTypeRequiredDescription
commentId string yes The comment ID to retrieve.
instagram.instagram_list_insights 4 parameters
Schema command
kosmo integrations:schema instagram.instagram_list_insights --json
ParameterTypeRequiredDescription
metric string no Comma-separated list of insight metrics (e.g. "impressions,reach,profile_views,follower_count").
period string no Aggregation period: "day", "week", "days_28", "month", or "lifetime". Defaults to "day".
since string no Start date for the insight data (UNIX timestamp or ISO date).
until string no End date for the insight data (UNIX timestamp or ISO date).
instagram.instagram_get_current_user 0 parameters
Schema command
kosmo integrations:schema instagram.instagram_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.