Skip to content
Docs

Posts

Instagram posts and reels in Unipile's Post object: a person's posts, one post, its comments and likes, commenting, liking, and creating a feed post.

Early access. Tell us what you're building and we'll set you up. Contact us

A post's id is its provider_id, Instagram's media id (a number). Reels are posts too. Every route that takes a post also takes its shortcode or its link (https://www.instagram.com/p/<shortcode>/, or /reel/<shortcode>/).

A Person's Posts#

Shell
curl -sS "https://api.lempile.com/api/v1/users/sam.example/posts?account_id=$ACCOUNT_ID&limit=12" \
  -H "X-API-KEY: $LEMPILE_API_KEY"
JSON
{
  "object": "PostList",
  "items": [
    {
      "object": "Post",
      "provider": "INSTAGRAM",
      "provider_id": "3502987465123456789",
      "has_audio": false,
      "has_liked": false,
      "like_count": 128,
      "comment_count": 9,
      "like_and_view_counts_disabled": false,
      "comments_disabled": false,
      "accessibility_caption": null,
      "caption": {
        "edited": false,
        "has_translation": false,
        "created_at": 1796149267,
        "text": "New glazes, out of the kiln today."
      },
      "preview_image": { "url": "https://…", "width": 1080, "height": 1350 },
      "owner": {
        "id": "48210937561",
        "username": "sam.example",
        "profile_pic_url": "https://…",
        "is_verified": false,
        "is_private": false
      },
      "location": { "name": "Lyon, France", "lat": 45.764, "lng": 4.8357 }
    }
  ],
  "cursor": "<cursor>",
  "paging": { "page_count": 1 }
}
  • Newest first, as the profile shows them. limit 1 to 100 (10 by default), cursor for the next page.
  • video (url, width, height) on a video or reel; has_audio says whether it has sound.
  • caption.created_at is when it was posted, in seconds since 1970.
  • A private account's posts can only be read when the account follows it.

One Post#

Shell
curl -sS "https://api.lempile.com/api/v1/posts/DBx1yZaN0pQ?account_id=$ACCOUNT_ID" \
  -H "X-API-KEY: $LEMPILE_API_KEY"

The same Post.

Comments#

Shell
curl -sS "https://api.lempile.com/api/v1/posts/3502987465123456789/comments?account_id=$ACCOUNT_ID&limit=20" \
  -H "X-API-KEY: $LEMPILE_API_KEY"
JSON
{
  "object": "CommentList",
  "items": [
    {
      "object": "Comment",
      "id": "18034567890123456",
      "provider_id": "18034567890123456",
      "author": {
        "provider_id": "50112233445",
        "messaging_id": "",
        "public_identifier": "lou.sample",
        "pk": "50112233445",
        "profile_pic_url": "https://…",
        "is_verified": false
      },
      "text": "That blue!",
      "created_at": 1796150012,
      "is_covered": false,
      "child_comment_count": 1,
      "restricted_status": null,
      "has_liked_comment": false,
      "giphy_media_info": null,
      "parent_comment_id": null,
      "comment_like_count": 2
    }
  ],
  "cursor": "<cursor>",
  "total_items": 9,
  "paging": { "start": null, "page_count": 1, "total_count": 9 }
}
  • In the order the post's page loads them. limit 1 to 100 (20 by default), cursor for more. sort_by=MOST_RELEVANT answers 501: Instagram's web picks its own order.
  • comment_id (a comment's provider_id): that comment's replies.
  • An author's id is null when Instagram's page didn't show it.

Comment On A Post#

Shell
curl -sS -X POST "https://api.lempile.com/api/v1/posts/3502987465123456789/comments" \
  -H "X-API-KEY: $LEMPILE_API_KEY" \
  -H "Idempotency-Key: comment-sam-1" \
  -H "Content-Type: application/json" \
  -d '{ "account_id": "'"$ACCOUNT_ID"'", "text": "Lovely work, @sam.example" }'

201:

JSON
{ "object": "CommentSent", "comment_id": "18034567890123999" }
  • Idempotency-Key is required.
  • text: 1 to 1,250 characters. @username mentions the person.
  • comment_id: answer that comment instead.
  • Typed in the post's own comment box. Its dry run types the comment and clears it: Instagram shows nobody a comment being typed.
  • 2 minutes apart, 20 a day per account.

Likes#

GET /posts/{post_id}/reactions?account_id= lists who liked a post (with comment_id, a comment), as the likes list loads:

JSON
{
  "object": "PostReactionList",
  "items": [
    {
      "object": "PostReaction",
      "value": "LIKE",
      "post_id": "3502987465123456789",
      "comment_id": null,
      "author": {
        "id": "50112233445",
        "type": "INDIVIDUAL",
        "name": "Lou Sample",
        "headline": "",
        "profile_url": "https://www.instagram.com/lou.sample/",
        "profile_picture_url": "https://…",
        "network_distance": null,
        "public_identifier": "lou.sample",
        "is_verified": false,
        "is_private": false
      }
    }
  ],
  "paging": { "cursor": null, "start": null, "page_count": 1, "total_count": 128 }
}

limit 1 to 100 (20 by default), cursor for more. An author's id is null when Instagram's page didn't show it.

POST /posts/reaction likes a post, or a comment with comment_id:

Shell
curl -sS -X POST "https://api.lempile.com/api/v1/posts/reaction" \
  -H "X-API-KEY: $LEMPILE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "account_id": "'"$ACCOUNT_ID"'", "post_id": "3502987465123456789", "reaction_type": "like" }'
JSON
{ "object": "ReactionAdded" }

reaction_type is like, the only reaction Instagram has. 30 seconds apart, 60 a day per account.

Create A Post#

POST /posts (multipart/form-data) publishes a feed post through Instagram's own Create:

Field
account_id Required.
text The caption, 2,200 characters at most (Instagram's limit). @username mentions someone.
attachments At least one file: JPEG or PNG pictures (8 MB each), MP4 or MOV videos (50 MB). 10 files and 50 MB at most in all.
location A place to tag. The best match is used; no match leaves the post untagged.

Idempotency-Key is required. Instagram picks a video's cover: video_thumbnail answers 501.

JSON
{ "object": "PostCreated", "post_id": "3502987465123457001", "status": "PUBLISHED" }

201 once Instagram shows the post. 202 with status: "PROCESSING" when Instagram is still processing it (a video, often): read the account's posts a little later. 3 posts a day per account.

A long video can take longer than the 140 seconds a request waits. Send Prefer: respond-async to get 202 as soon as Lempile starts the post, with Preference-Applied: respond-async, the key in the Idempotency-Key header and its receipt in the Location header (/api/v1/writes/{key}):

JSON
{ "object": "PostCreated", "post_id": null, "provider": "INSTAGRAM", "status": "PROCESSING" }

Then read GET /writes/{key} until its state is done (response is the post) or failed (Write Receipts).

A story (post_type: "story") answers 501: Instagram's web can't make one.

Was this page helpful?