API Guide
This guide is current for aiograpi-rest v6.0.0, which wraps
aiograpi==1.0.9.
Authentication
Protected routes accept the saved session ID through the X-Session-ID header.
Swagger UI exposes this through the green Authorize button.
Session-creation routes:
POST /auth/loginPOST /auth/login/by/sessionidPATCH /auth/settingsaccepts an optional saved session and returns a new session ID after settings are loaded.
Session-aware routes still accept legacy sessionid values from query
parameters, form data, or a sessionid cookie for backwards compatibility.
Session Client Options
POST /auth/login and POST /auth/login/by/sessionid accept optional proxy,
locale, and timezone form fields. The service persists the proxy separately
from aiograpi settings because Client.get_settings() does not include proxy
transport state.
Use PATCH /auth/settings to update an existing session after login. Send the
session through X-Session-ID or the legacy sessionid form field, then pass
any of:
settings: a JSON string fromaiograpi.Client.get_settings().proxy: proxy URL for all restored clients. Pass an empty value to clear it.locale: locale such asen_US.timezone: timezone offset in seconds, such as10800.
Two-Factor Login
If POST /auth/login returns TwoFactorRequired, retry the same endpoint with
the same username and password plus verification_code.
GET /auth/totp/seed generates a TOTP seed for the authenticated session.
GET /auth/totp/code?seed=... generates the current six-digit TOTP code from a
seed without requiring a session.
If it returns ChallengeRequired, resolve the Instagram challenge in the
account/session context first, then retry login or import a known-good saved
session through PATCH /auth/settings.
If the challenge asks for an SMS or email code, call
POST /auth/challenge/resolve with the same last_json challenge payload and
the security_code from Instagram. The service injects that code into
aiograpi for one request and restores the default handler afterwards, so the
server never waits for stdin.
If Instagram says the username does not belong to an account, the API returns
HTTP 401 with a hint to check the username and retry POST /auth/login.
If Instagram returns FeedbackRequired, PleaseWaitFewMinutes, or
RateLimitError, the API returns HTTP 429. These errors usually mean Instagram
is throttling the account or action; pause automation, reduce request rate, and
check account and proxy health before retrying.
Route Conventions
GETroutes read or download data.POSTroutes create sessions, create actions, or upload media.PATCHroutes update state.DELETEroutes remove or undo state.- Paths use slash-separated resources such as
/story/upload/by/url. - State reversals use the same resource path with
DELETE: for example,POST /media/likelikes media andDELETE /media/likeunlikes it.
Relationship Actions
User relationship routes use POST to create or enable a relationship state and
DELETE to remove or disable it.
POST /user/followfollows a user.DELETE /user/followunfollows a user.DELETE /user/followerremoves a follower.POST /account/follow/request/approveapproves a pending follow request.DELETE /account/follow/requestdeclines a pending follow request.POST /account/follow/requests/approveapproves multiple pending follow requests.DELETE /account/follow/requestsdeclines multiple pending follow requests.POST /user/close-friendadds a user to close friends.DELETE /user/close-friendremoves a user from close friends.POST /user/notifications/postsenables post notifications for a user.DELETE /user/notifications/postsdisables post notifications for a user.POST /user/notifications/storiesenables story notifications for a user.DELETE /user/notifications/storiesdisables story notifications for a user.POST /user/notifications/reelsenables Reel notifications for a user.DELETE /user/notifications/reelsdisables Reel notifications for a user.POST /user/notifications/videosenables video notifications for a user.DELETE /user/notifications/videosdisables video notifications for a user.
Account Settings
GET /account/securityreturns security metadata for the authenticated account.PATCH /account/biographyupdates only the authenticated account biography.PATCH /account/external-urlreplaces the authenticated account external profile URL.DELETE /account/external-urlclears the authenticated account external URL by asking Instagram to replace it with an empty URL. If Instagram rejects an empty URL for the account, remove the concrete bio link viaDELETE /account/bio-links.DELETE /account/bio-linksremoves one or more bio links bylink_ids.PATCH /account/passwordchanges the authenticated account password.POST /account/password/resetrequests a password reset link or code by username, email, or phoneidentifier.POST /account/email/confirmationsends an email confirmation code.POST /account/email/confirmconfirms a pending email change withemailandcode.POST /account/phone/confirmsends a phone confirmation code.
Notification Settings
GET /notifications/settingsreturns supported notificationcontent_typevalues and allowed setting values.PATCH /notifications/settingsupdates one notification setting bycontent_typeandsetting_value. Most notification settings acceptoff,following_only, oreveryone.PATCH /notifications/settingswithcontent_type=mute_allaccepts onlycancel,15_minutes,1_hour,2_hour,4_hour, or8_hour.DELETE /notifications/settingsdisables all supported notification settings for the authenticated account.
OpenAPI
- Swagger UI:
/docs - Raw schema:
/openapi.json
The schema uses client-friendly operation IDs and request schema names so it can be passed directly into OpenAPI client generators.
Search
Search routes live under the Search tag and hide Instagram's internal
fbsearch naming behind resource-oriented paths:
GET /search/userssearches accounts by query.GET /search/accountssearches accounts through Instagram's newer search surface and supportspage_token.GET /search/followerssearches inside a user's followers.GET /search/followingsearches inside accounts a user follows.GET /search/hashtagssearches hashtags.GET /search/musicsearches music tracks.GET /search/locationssearches locations by name or coordinates.GET /search/placessearches places by query with optionallatandlngranking context.GET /search/topreturns Instagram's blended top search results.GET /search/top/flatreturns the older flat blended top-search list.GET /search/web/topreturns web top-search results.GET /search/web/hashtagsreturns web hashtag search results.GET /search/reelsreturns Reel search results.GET /search/itemreturns one raw Instagram search tab byitem_idandsearch_surface.GET /search/suggested/usersreturns suggested users for a profile.GET /search/recentreturns the authenticated account's recent searches.GET /search/typeaheadreturns autocomplete suggestions for a partial query.GET /search/typeahead/streamreturns the raw typeahead stream envelope.GET /search/typeahead/usersreturns flattened typeahead user suggestions.
/search/top, /search/top/flat, /search/web/top, /search/reels,
/search/accounts, /search/typeahead, /search/typeahead/stream, and
/search/item return raw Instagram-shaped objects because their payloads vary
by ranking surface and cursor state.
Share
Share routes decode Instagram share URLs or encoded share codes without creating or changing Instagram state.
GET /share?url=...returns the decoded sharetype,pk, and extractedcodefor a share URL.GET /share?code=...returns the decoded sharetype,pk, and originalcodefor an encoded share code.
Highlight
Highlight routes manage Story highlights and accept either the Instagram highlight PK or a highlight URL where lookup can be resolved from a URL:
GET /highlight?highlight_pk=...returns highlight details by PK.GET /highlight?url=...resolves the PK from the URL and returns highlight details.PATCH /highlightupdates title, cover, and story membership. A title-only patch uses aiograpi's dedicated title-change method, andcover_pictureuploads a cover image through aiograpi's dedicated cover-change method.
Story
Story archive routes expose both archive day pages and the actual archived story media collection:
GET /story/archivereturns paginated archive day groups withitemsandnext_cursor.GET /story/archive/mediareturns archived stories from the authenticated account. Passamount=0to keep aiograpi's default of returning all available archived stories, or a positive amount to limit the list.GET /story/stickersreturns Instagram's raw story sticker tray payload for building story upload decorations.GET /story/usersreturns story lists for multiple users. Pass repeateduser_idsquery parameters, for exampleuser_ids=123&user_ids=456.
ID Parameters
Instagram user primary keys are exposed as strings in the REST API. Use
user_id=25025320 for a single user and repeat user_ids for lists, for
example user_ids=123&user_ids=456. Treat them as opaque IDs in generated
clients even when they contain only digits.
User Discovery
User discovery routes live under the target user context and return raw
Instagram-shaped objects where aiograpi exposes variable discovery payloads:
GET /user/suggestionsreturns suggested users for a target profile.GET /user/suggestions/detailsreturns expanded social context for suggestion IDs from/user/suggestions.GET /user/recommendationsreturns category-based recommended accounts for a target profile.GET /user/featured/accountsreturns Instagram's featured-account suggestions for a target profile.GET /user/fundraiserreturns standalone fundraiser info for a target profile.GET /user/creatorreturns creator metadata for a target profile as{ "user": ..., "info": ... }.GET /user/profile/webreturns Instagram's web-profile payload for a username.GET /user/streamreturns a profile stream byuser_idorusername.view=flatreturns the merged user payload;view=rawreturns Instagram's stream envelope.GET /user/friendshipsreturns relationship summaries for repeateduser_idsquery parameters.
GET /account/feed/new belongs to the authenticated account context and returns
whether Instagram says new timeline feed items are available.
GET /account/feed/user/stream-item returns a feed stream item for the
authenticated account.
GET /account/family returns Instagram's account-family payload for the
authenticated account.
Reels
Global Reels feed routes live under the Reels tag and return arrays of media
objects. They accept amount and last_media_pk where the underlying
aiograpi method supports feed continuation.
GET /reelsreturns connected Reels media.GET /reels/friendsreturns Friends tab Reels media.GET /reels/explorereturns Explore Reels media.GET /reels/timelinereturns Reels media for acollection_pk.
Clip upload and utility routes live under the Clip (Reels) tag:
GET /clip/creation/inforeturns the raw Reel creation preflight config.GET /clip/trial-eligibilitychecks whether Trial Reels are enabled for the authenticated account.GET /clip/share/facebook/configreturns Facebook sharing config; passdevice_statusas an optional JSON-encoded query parameter.GET /clip/templatereturns the raw clip template payload for a sourcemedia_id.POST /clip/uploaduploads a Reel from a video file.POST /clip/upload/by/urluploads a Reel from a video URL.POST /clip/upload/with/musicuploads a Reel from a video file with a JSON-encodedtrackpayload and optional JSON-encodedextra_data.POST /clip/pinpins a Reel bymedia_pk.DELETE /clip/pinunpins a Reel bymedia_pk.
Saved Collections
Saved collection routes live under the authenticated account context because they read the current account's saved Instagram collections.
GET /account/collectionslists saved collections.GET /account/collectiongets one saved collection bycollection_pkorname.GET /account/collection/medialists media in one saved collection bycollection_pkorname.GET /account/archive/medialists archived media for the authenticated account withitemsandnext_cursor.
Explore
Explore routes return raw Instagram-shaped objects because the Explore payload depends on ranking, layout, and media type.
GET /explorereturns the authenticated account's Explore page.GET /explore/mediareturns Explore metadata for onemedia_pk.
Tracks And Music
Track routes return Instagram music track data for Reels and post creation workflows.
GET /trackgets a track byidorcanonical_id.GET /track/streamreturns streamed media for a trackid.GET /track/download/by/urldownloads track audio from a URL.GET /music/feed/browserreturns music candidates for feed posts.GET /music/searchsearches the current app music catalog.GET /music/keywordssearches music typeahead keywords.GET /music/trendingreturns trending music candidates.GET /music/trends/topreturns top music trends.GET /music/clips/browserreturns music candidates for Reels.POST /music/bookmarkbookmarks original audio.GET /music/original-audio/title/availabilitychecks whether an original audio title is valid.
Livestreams
Livestream routes manage the authenticated account's Instagram Live broadcast
state. They are exposed as resource state changes instead of start/end
action paths:
POST /media/livestreamcreates a live broadcast and returns stream server metadata.GET /media/livestreamreturns broadcast info bybroadcast_id.PATCH /media/livestreamchanges the broadcaststatetostartedorended.GET /media/livestream/commentslists live comments for abroadcast_id.GET /media/livestream/viewerslists live viewers for abroadcast_id.POST /media/notecreates a note attached to a media item.DELETE /media/notedeletes a media-attached note bynote_id.
Notes
GET /noteslists visible notes.GET /notereturns a visible note byusername.GET /note/textreturns only the visible note text byusername.POST /notecreates a text note.POST /note/musiccreates a note with music from a track payload returned byGET /notes/music/browser.PATCH /notes/last-seenmarks notes as seen.DELETE /notedeletes one note bynote_id.GET /notes/music/browserreturns music candidates for Notes.
Comment Utilities
Comment routes live under Media (Post) because Instagram comments always
belong to a media object.
GET /media/commentslists a paginated comment page withnext_cursor.GET /media/comments/streamlists a stream comment page withmin_cursorandmax_cursor.POST /media/commentcreates a comment or reply.DELETE /media/commentdeletes one comment from media.GET /media/comment/replieslists replies for one comment.POST /media/comment/likelikes a comment.DELETE /media/comment/likeunlikes a comment.GET /media/comment/likerslists users who liked a comment.POST /media/comment/pinpins a comment.DELETE /media/comment/pinunpins a comment.GET /media/comment/infosreturns comment counters for media IDs.POST /media/comment/check/offensivechecks whether text is offensive for the target media.
Direct
GET /direct/channelslists Direct channels, optionally filtered byuser_idand repeatedthread_subtypes.GET /direct/interop/upgradedreports whether the account has upgraded interop messaging.GET /direct/requests/previewreturns a lightweight pending requests preview.GET /direct/genai/botslists generated AI bot suggestions for Direct.PATCH /direct/e2ee/eligibilityupdates the account's Direct E2EE eligibility state.GET /direct/pending/inboxlists pending direct request threads up toamount.GET /direct/spam/inboxlists spam direct request threads up toamount.POST /direct/request/approveapproves a direct message request thread.POST /direct/thread/messagereplies in an existing direct thread.DELETE /direct/messageunsends a direct message.POST /direct/cutout/stickersends a cutout sticker to eitheruser_idsorthread_ids.POST /direct/video/uploaduploads a video through aiograpi's story-direct flow withcaption, optionalthumbnail, repeatable JSONmentionsandmedias, requiredthread_ids, and optional JSONextra_data.
Pagination
Paginated read-list routes return an object with items and next_cursor.
Pass the returned next_cursor as cursor on the next request to continue
from the previous page. This shape is used for:
GET /direct/inboxGET /direct/pendingGET /direct/spamGET /account/archive/mediaGET /hashtag/media/recentGET /hashtag/media/topGET /location/media/recentGET /location/media/topGET /media/commentsGET /media/comments/streamreturnsitems,min_cursor, andmax_cursorinstead ofnext_cursor.GET /story/archiveGET /story/viewersGET /user/reelsGET /account/follow/requestsGET /user/followersGET /user/followingGET /user/postsGET /user/tagged/postsGET /user/videos
User post collection routes accept either user_id for numeric Instagram
user PKs or username for usernames. If a legacy client passes a username in
user_id, the service resolves it before calling aiograpi.
Additional discovery collection routes return plain arrays when aiograpi does
not expose a cursor for the underlying method:
GET /hashtag/reelsGET /location/guidesGET /user/guidesGET /user/pinned/posts
Form JSON Fields
Story upload decoration fields such as mentions, locations, links,
hashtags, and stickers are form fields. Repeat the field with one
JSON-encoded object per value, or pass a single JSON array of objects.
For mentions, locations, and hashtags, omitted x, y, width, height, or
rotation values default to a centered story position before the request is
sent to aiograpi.
Feed upload and edit metadata use JSON-encoded form strings too. The upload
endpoints for photo, video, clip/Reels, IGTV, album/carousel, and the media
edit endpoint accept usertags as one JSON array or repeated JSON-encoded
Usertag values, and location as one JSON-encoded Location object. Leave
these fields empty or omit them when no metadata is needed.
Music upload endpoints also use JSON strings: track is a JSON-encoded
Track object returned by music search/browser routes, and extra_data is
optional configure data. This applies to:
POST /photo/upload/with/musicPOST /clip/upload/with/musicPOST /album/upload/with/music
Media notes use the same JSON field style for optional extra_data:
POST /media/noteDELETE /media/note
device_status is an optional JSON object for
GET /clip/share/facebook/config.
System Endpoints
GET /healthreturns{"status":"ok"}for liveness.GET /readychecks storage and required runtime dependencies.GET /metricsexports Prometheus text metrics.GET /buildreturns service build metadata.GET /depsreturns runtime dependency versions.