Skip to content

Profile

Rahil edited this page Apr 14, 2026 · 3 revisions

πŸ“‹ ProfileData β€” Key Fields

  • username β€” handle name
  • pk β€” numeric ID
  • fullName / name
  • biography
  • profilePicURL
  • isPrivate, isVerified, isBusinessAccount
  • posts, followers, followings (counts)

πŸ› οΈ Examples

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

1. Fetch a profile

var profile = insta.getProfile("target_username");
System.out.println(profile.username + " (" + profile.pk + ") β€” " + profile.biography);

2. Follow / Unfollow

profile.follow();   // follow user
profile.unfollow(); // unfollow user

3. Get posts (PostPaginator)

var postsPaginator = profile.getPosts();
while (postsPaginator.hasNext()) {
    var page = postsPaginator.next();
    page.forEach(post -> System.out.println(post.id + " β€” " + post.caption));
}

4. Followers & Followings (ProfilePaginator)

// Followers
var followersPaginator = profile.getFollowers();
while (followersPaginator.hasNext()) {
    var page = followersPaginator.next();
    page.forEach(p -> System.out.println(p.username + " β€” " + p.profilePicURL));
}

// Followings
var followingsPaginator = profile.getFollowings();
if (followingsPaginator.hasNext()) {
    var firstPage = followingsPaginator.next();
    // ...
}

5. Stories & Highlights

var stories = profile.getStory();
stories.forEach(s -> System.out.println("story id: " + s.id + " url: " + s.getUrl()));

var highlights = profile.getHighlights();
highlights.forEach(h -> System.out.println("highlight id: " + h.id));

6. Typical flow

var profile = insta.getProfile("target_username");
profile.follow();

var postsPaginator = profile.getPosts();
if (postsPaginator.hasNext()) {
    var firstPage = postsPaginator.next();
    firstPage.forEach(p -> System.out.println(p.id + " β€” " + p.caption));
}

πŸ’‘ Tips

  • Paginators (PostPaginator, ProfilePaginator) behave like iterators:
    • hasNext() β†’ more pages available
    • next() β†’ fetch next page
  • getStory() and getHighlights() return lists (may be empty).
  • Use profile.pk for endpoint-specific requests.
  • Preserve your AUTH_TOKEN to avoid logging in repeatedly.

Clone this wiki locally