The PublicAPIs class in JxInsta’s Web module exposes four static methods that call Instagram’s unauthenticated public endpoints. You do not need to create a JxInsta instance or provide any credentials — call the methods directly on the class. Because these endpoints are public, they carry stricter rate limits than authenticated endpoints, and some may stop responding temporarily if called too frequently.
PublicAPIs is part of the com.jxinsta.web.endpoints package. It is not available in the Mobile module. Add the Web module dependency to your project before using it.
Fetching post info by URL
PublicAPIs.getPostInfo(String url) takes a standard Instagram post URL and returns a PostData object containing the post’s metadata. No session token is required.
PostData post = PublicAPIs.getPostInfo("https://www.instagram.com/p/ABC123xyz/");
System.out.println(post.id); // numeric media ID
System.out.println(post.shortcode); // "ABC123xyz"
System.out.println(post.caption); // caption text
System.out.println(post.likes); // like count
System.out.println(post.mediaType); // IMAGE / VIDEO / CAROUSEL
System.out.println(post.download_url[0]); // direct media URL
The method extracts the shortcode from the URL automatically, so you can pass the full URL as-is.
The PostData object returned by getPostInfo() is read-only. It does not carry an auth token, so calling action methods like like() or comment() on it will fail. Use an authenticated Post object for interactive operations.
Fetching a profile by username
PublicAPIs.getProfileInfo(String username) returns a ProfileData object for the given username using Instagram’s web_profile_info public endpoint.
ProfileData profile = PublicAPIs.getProfileInfo("natgeo");
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.isVerified); // true/false
System.out.println(profile.followers); // follower count
System.out.println(profile.posts); // total post count
getProfileInfo() hits a public endpoint with very strict rate limits. Calling it in a loop or in quick succession for multiple usernames is likely to result in temporary blocks. Add a delay of several seconds between calls and avoid using this method for bulk lookups.
Fetching a user’s posts by numeric ID
PublicAPIs.getPosts(String pk, int count, String cursor) returns a page of PostData objects for the account identified by pk (the numeric user ID). Pass null as the cursor to retrieve the first page.
// Fetch the first 12 posts for user with pk "25025320"
List<PostData> posts = PublicAPIs.getPosts("25025320", 12, null);
for (PostData post : posts) {
System.out.println(post.shortcode + " — " + post.caption);
}
To paginate, capture the cursor from the last response and pass it to the next call. The API does not return a paginator object for this method — pagination is manual.
String cursor = null;
do {
List<PostData> page = PublicAPIs.getPosts("25025320", 12, cursor);
if (page.isEmpty()) break;
for (PostData post : page) {
System.out.println(post.shortcode);
}
// Capture the cursor for the next page from your own state tracking
// (cursor management depends on how you store the end_cursor from the GraphQL response)
break; // remove this to keep paginating
} while (cursor != null);
If you need automatic cursor management, use PublicAPIs.hashtagSearch() for hashtag content, which returns a HashtagPaginator that handles the cursor for you. For user posts, manage the cursor manually or use an authenticated PostPaginator via a logged-in client.
PublicAPIs.hashtagSearch(String tag, String after) returns a HashtagPaginator that iterates public posts associated with a hashtag. Pass the tag without the # symbol. Pass null as the cursor to start from the first page.
HashtagPaginator paginator = PublicAPIs.hashtagSearch("astrophotography", null);
while (paginator.hasNext()) {
List<HashtagPost> page = paginator.next();
for (HashtagPost post : page) {
System.out.println(post.username() + ": " + post.caption());
System.out.println("Code: " + post.shortcode());
System.out.println("ID: " + post.id());
System.out.println("Thumbnail:" + post.displayPicture());
System.out.println("Video: " + post.downloadUrl());
System.out.println("Views: " + post.views());
}
// Add a delay between pages to avoid rate limits
Thread.sleep(2000);
}
To resume from a specific page, pass the cursor string instead of null:
HashtagPaginator paginator = PublicAPIs.hashtagSearch("astrophotography", "QVFDa...");
Each page of hashtagSearch() returns up to 29 posts. HashtagPost is a Java record — access its fields with accessor methods (shortcode(), caption(), username(), displayPicture(), views(), downloadUrl()).
Rate limits
All four PublicAPIs methods hit unauthenticated public Instagram endpoints. Instagram enforces rate limits by IP address on these endpoints, and the thresholds are much lower than for authenticated API calls.
getProfileInfo() is the most sensitive. Avoid calling it more than a few times per minute.
getPostInfo() and getPosts() are slightly more permissive but still require care in loops.
hashtagSearch() via HashtagPaginator should include a delay between pages.
Exceeding the public rate limits will cause Instagram to return errors for all PublicAPIs methods from your IP until the limit resets. If you need to fetch data at scale, use an authenticated client with JxInsta instead.
HashtagPost field reference
HashtagPost is a record in com.jxinsta.web.endpoints. All fields are accessed through auto-generated accessor methods.
| Accessor | Type | Description |
|---|
shortcode() | String | The alphanumeric shortcode that appears in the post URL. |
id() | String | The numeric media ID. |
caption() | String | The caption text of the post. |
username() | String | The username of the account that posted it. |
displayPicture() | String | URL of the post’s display thumbnail. |
views() | long | The view or play count for the post. |
downloadUrl() | String | Direct URL to the video file for the post. |