Skip to main content
The web module models Instagram profiles with two complementary classes. ProfileData is a read-only data container populated from the API response. Profile extends it with authenticated action methods that let you follow users, iterate their posts and followers, and fetch their stories or highlights.

Package

com.jxinsta.web.endpoints.profile

ProfileData

ProfileData holds the raw fields returned by Instagram for any user. It serves as the base class for Profile and is also returned directly by PublicAPIs.getProfileInfo.

Fields

username
String
The account’s username (without the @ symbol).
pk
String
The unique numeric identifier for this account (Instagram’s internal primary key).
name
String
The full display name as shown on the profile page (full_name in the API).
biography
String
The profile bio text. Empty string if the user has not set a bio.
profilePicURL
String
URL of the user’s profile picture.
isBusinessAccount
boolean
true if the account is registered as a business or creator account.
isPrivate
boolean
true if the account is set to private.
isVerified
boolean
true if the account has a verified badge.
posts
int
Total number of posts published by the user. May be 0 if the endpoint that populated this object does not return a post count.
followers
int
Follower count. Returns -1 when the endpoint did not include follower data.
followings
int
Following count. Returns -1 when the endpoint did not include following data.

Profile

Profile extends ProfileData and is returned by JxInsta.getProfile. It holds an authenticated session internally and exposes methods to paginate posts, followers, and followings, and to perform social actions.

getPosts(String cursor)

Returns a paginator that yields the user’s media posts in reverse-chronological order, 12 at a time.
Profile profile = client.getProfile("natgeo");
PostPaginator pager = profile.getPosts(null);
while (pager.hasNext()) {
    pager.next().forEach(p -> System.out.println(p.shortcode));
}
cursor
String
Opaque pagination cursor from a previous page. Pass null to start from the most recent post.
Returnscom.jxinsta.web.paginators.PostPaginator

getFollowers(String cursor)

Returns a paginator over the accounts that follow this user, fetching up to 200 per page.
ProfilePaginator followers = profile.getFollowers(null);
while (followers.hasNext()) {
    followers.next().forEach(f -> System.out.println(f.username));
}
cursor
String
Pagination cursor. Pass null to start from the first page.
Returnscom.jxinsta.web.paginators.ProfilePaginator

getFollowings(String cursor)

Returns a paginator over the accounts this user is following, fetching up to 200 per page.
ProfilePaginator following = profile.getFollowings(null);
while (following.hasNext()) {
    following.next().forEach(f -> System.out.println(f.username));
}
cursor
String
Pagination cursor. Pass null to start from the first page.
Returnscom.jxinsta.web.paginators.ProfilePaginator

getStory()

Fetches the user’s currently active story reels. Returns null when the user has no active stories (or their account is private and you are not a follower).
List<Story> stories = profile.getStory();
if (stories != null) {
    stories.forEach(s -> System.out.println(s));
}
ReturnsList<Story> or null ThrowsInstagramException

getHighlights()

Fetches all story highlights published by this user. Returns null if the user has no highlights.
List<Story> highlights = profile.getHighlights();
if (highlights != null) {
    highlights.forEach(h -> System.out.println(h));
}
ReturnsList<Story> or null ThrowsInstagramException

follow()

Sends a follow request to this user. For private accounts this creates a pending request; for public accounts the follow takes effect immediately.
profile.follow();
Returnsvoid ThrowsInstagramException

unfollow()

Unfollows this user.
profile.unfollow();
Returnsvoid ThrowsInstagramException

block()

Blocks this user. The blocked account can no longer view your profile or contact you.
profile.block();
Returnsvoid ThrowsInstagramException