Skip to main content
The Profile class is the main entry point for interacting with any Instagram account. You retrieve a Profile by calling getProfile() on an authenticated JxInsta instance. The returned object exposes profile metadata through ProfileData fields, and lets you take actions such as following, unfollowing, and blocking the account, as well as paginating posts, followers, and followings.

Fetching a profile

1

Create an authenticated client

Instantiate JxInsta with credentials or an existing session token. The Mobile and Web clients have slightly different constructors.
// Log in with username and password
JxInsta insta = new JxInsta("your_username", "your_password");

// Or reuse an existing auth token
JxInsta insta = JxInsta.getInstance("Bearer IGT:2:...");
2

Call getProfile()

Pass the target account’s username. Both clients expose the same method signature.
Profile profile = insta.getProfile("natgeo");
3

Read ProfileData fields

Profile extends ProfileData, so all fields are directly accessible on the returned object.
System.out.println(profile.username);         // "natgeo"
System.out.println(profile.pk);               // numeric user ID
System.out.println(profile.name);             // display name
System.out.println(profile.biography);        // bio text
System.out.println(profile.profilePicURL);    // HTTPS image URL
System.out.println(profile.isPrivate);        // true/false
System.out.println(profile.isVerified);       // true/false
System.out.println(profile.isBusinessAccount);// true/false
System.out.println(profile.posts);            // total post count
System.out.println(profile.followers);        // follower count
System.out.println(profile.followings);       // following count
On the Web client, followers and followings return -1 when the value is not included in the API response for a given endpoint. Check for -1 before displaying the count.

Profile actions

Once you have a Profile object you can follow, unfollow, or block the account. All three methods throw InstagramException on failure.
profile.follow();    // send a follow request
profile.unfollow();  // remove an existing follow
profile.block();     // block the account
These actions are performed as the authenticated account. There is no confirmation step — calling block() immediately blocks the user.

Fetching stories and highlights

getStory() returns the account’s currently active story reels. getHighlights() returns all items from the account’s saved highlight collections.
List<Story> stories    = profile.getStory();      // active stories
List<Story> highlights = profile.getHighlights(); // highlight items
Both methods return an empty list (Mobile) or null (Web) when no content is available, so check before iterating.
List<Story> stories = profile.getStory();
if (stories != null && !stories.isEmpty()) {
    for (Story story : stories) {
        System.out.println(story);
    }
}

Paginating posts

getPosts() returns a PostPaginator which implements Iterator<List<Post>>. Call hasNext() before each next() call to avoid a NoSuchElementException.
The Mobile paginator takes no cursor argument — pagination state is managed internally.
PostPaginator paginator = profile.getPosts();

while (paginator.hasNext()) {
    List<Post> page = paginator.next();
    for (Post post : page) {
        System.out.println(post.id + " — " + post.caption);
    }
}

Paginating followers and followings

getFollowers() and getFollowings() return a ProfilePaginator which implements Iterator<List<Profile>>. Each page contains up to 200 profiles (Mobile) or 50 profiles (Web).
ProfilePaginator followerPages = profile.getFollowers();

while (followerPages.hasNext()) {
    List<Profile> page = followerPages.next();
    for (Profile follower : page) {
        System.out.println(follower.username + " (" + follower.pk + ")");
    }
}
Use getFollowings() in the same way to iterate over accounts that the profile follows.
Each Profile object returned by the paginator is a full Profile instance, so you can call follow(), getStory(), and other actions directly on paginated results.

ProfileData field reference

FieldTypeDescription
usernameStringThe account’s username handle.
pkStringThe numeric user ID (primary key).
nameStringThe full display name.
biographyStringThe bio text from the profile.
profilePicURLStringURL of the profile picture.
isPrivatebooleanWhether the account is private.
isVerifiedbooleanWhether the account has a verified badge.
isBusinessAccountbooleanWhether the account is a business profile.
postsintTotal number of posts published.
followersintNumber of followers (-1 if not available).
followingsintNumber of accounts followed (-1 if not available).