PostData is the data carrier populated from the Instagram mobile API JSON for a single media item. Post extends PostData, adds an auth token, and exposes action methods — liking, disliking, commenting, retrieving likers, and paginating comments. You obtain a Post from JxInsta.getPost(url) or via a FeedPaginator. The Post.MEDIA_TYPE enum identifies whether the item is an image, video, or carousel album.
Post.MEDIA_TYPE enum
The MEDIA_TYPE enum reflects the media_type integer returned by the mobile API. It is stored in PostData.mediaType.
| Constant | API value | Description |
|---|---|---|
IMAGE | 1 | A single still image post. |
VIDEO | 2 | A video or Reel post. |
CAROUSEL | 8 | A carousel album containing multiple images or videos. |
Post.java
PostData fields
PostData is populated by the PostData(JSONObject postData) constructor, which parses the raw API response.
The numeric media ID, resolved from
pk or id in the API response. Used as the identifier for all action endpoints.The URL-safe shortcode for the post, sourced from the
code field. Appears in the post URL as /p/<shortcode>/.The media type of the post — one of
IMAGE, VIDEO, or CAROUSEL. Determined by mapping the integer media_type field in the API response.The post caption text, sourced from
caption.text in the API response. null if no caption was set.The current like count for the post, sourced from
like_count.The total comment count for the post, sourced from
comment_count.An array of direct image/video URLs for download. Contains one element for
IMAGE posts (the highest-resolution candidate from image_versions2), and one element per slide for CAROUSEL posts. null for VIDEO posts that do not expose image_versions2.Static method
Post.getPost(String url)
A static convenience method that fetches post data using the public GraphQL endpoint, without requiring a mobile auth token. Suitable for reading public post metadata from unauthenticated contexts.
Post.java
The full URL of the Instagram post. The shortcode is extracted from the
/p/<shortcode>/ segment and used in the GraphQL variables payload.PostData
Throws — InstagramException
Post fields
In addition to all PostData fields, Post exposes:
Indicates whether additional pages are available in a paginatable context (e.g., when iterating a feed). Set externally by paginators.
Post methods
All methods below require the auth token bound at construction time.
like()
Sends a like on the post on behalf of the authenticated user.
Post.java
void
Throws — InstagramException
dislike()
Removes a previously placed like from the post.
Post.java
void
Throws — InstagramException
comment(String comment)
Posts a comment on this media item.
Post.java
The comment text to post. Must not be null (
@NotNull). Sent as the comment_text field in the request body.void
Throws — InstagramException
likers()
Fetches the list of usernames of accounts that have liked this post.
Post.java
List<String> — a list of usernames of accounts that liked the post.
Throws — InstagramException
getComments()
Returns a CommentPaginator for lazily iterating through comments on this post. No network request is made until the paginator is advanced.
Post.java
CommentPaginator
toString()
Returns a human-readable representation of the key post fields for logging and debugging.
Post.java