Skip to content
Rahil edited this page Apr 14, 2026 · 1 revision

This guide shows how to work with posts using JxInsta’s mobile API (com.jxinsta.mobile.endpoints.post).
You’ll learn how to fetch posts, like/unlike, comment, and explore likers & comments.

🔑 Setup

JxInsta insta = JxInsta.getInstance(AUTH_TOKEN);

⚠️ Most methods throw InstagramException (sometimes IOException). Always handle errors.

📥 Fetch a Post

var post = insta.getPost("https://www.instagram.com/p/SHORTCODE/");
System.out.println("id: " + post.id + " caption: " + post.caption);

🌐 Public PostData (No Auth)

var info = Post.getPost("https://www.instagram.com/p/SHORTCODE/");
System.out.println("shortcode: " + info.shortcode + " likes: " + info.likes);

❤️ Like / 💔 Unlike

post.like();    // like the post
post.dislike(); // unlike the post

👥 Get Likers

var likers = post.likers();
likers.forEach(System.out::println);

💬 Comment & Stream Comments

post.comment("Nice photo!");

var paginator = post.getComments();
while (paginator.hasNext()) {
    var page = paginator.next();
    page.forEach(c -> System.out.println(c.username + ": " + c.text));
}

📂 Posts of a Profile

var profile = insta.getProfile("some_user");
var pp = profile.getPosts();

while (pp.hasNext()) {
    var page = pp.next();
    page.forEach(p -> System.out.println(p.id + " — " + p.caption));
}

📝 Quick Notes

  • Use insta.getPost(url) for authenticated posts (like/comment).
  • Use Post.getPost(url) for public read-only info.
  • Paginators (PostPaginator, CommentPaginator) work like iterators (hasNext(), next()).
  • Respect Instagram’s limits when liking or commenting repeatedly.

📚 Classes Overview

  • Post → actions like like(), dislike(), comment(), getComments().
  • PostData → read-only metadata (id, caption, likes, comments, media type).
  • Comment → parsed comment object (id, username, text, createdAt, etc.).
  • CommentPaginator → scroll through comments page by page.
  • PostPaginator → scroll through a user’s posts.

✨ With these basics, you can fetch posts, interact with them, and explore comments with ease!

Clone this wiki locally