Skip to main content
PublicAPIs exposes four static methods that call Instagram’s unauthenticated endpoints. No login is required, which makes these methods ideal for read-only integrations, bots that only display content, or situations where storing credentials is not practical. Because these requests do not carry a session cookie, Instagram enforces stricter rate limits than authenticated endpoints — particularly on getProfileInfo.

Package

com.jxinsta.web.endpoints.PublicAPIs

Methods

getPostInfo(String url)

Fetches read-only metadata for any public Instagram post by its URL. The returned PostData object cannot be used to perform actions (like, comment, etc.); use JxInsta.getPost for interactive operations.
PostData data = PublicAPIs.getPostInfo("https://www.instagram.com/p/ABC123/");
System.out.println(data.caption);
System.out.println(data.likes);
System.out.println(data.download_url[0]);
url
String
required
Full URL of the Instagram post, e.g. https://www.instagram.com/p/CODE/. The shortcode is extracted automatically.
Returnscom.jxinsta.web.endpoints.post.PostData ThrowsInstagramException

getProfileInfo(String username)

Fetches public profile information for a user without requiring authentication.
This endpoint has strict rate limits enforced by Instagram. Repeated calls in a short window will result in an InstagramException with reason RATE_LIMITED or THROTTLED. Avoid polling this method in tight loops.
ProfileData profile = PublicAPIs.getProfileInfo("instagram");
System.out.println(profile.name);
System.out.println(profile.biography);
System.out.println(profile.followers);
username
String
required
The Instagram username to look up (without @).
Returnscom.jxinsta.web.endpoints.profile.ProfileData ThrowsInstagramException

getPosts(String pk, int count, String cursor)

Fetches a page of posts for a given user, identified by their numeric ID (pk). Use ProfileData.pk to obtain the numeric ID first.
ProfileData profile = PublicAPIs.getProfileInfo("instagram");
List<PostData> posts = PublicAPIs.getPosts(profile.pk, 12, null);
posts.forEach(p -> System.out.println(p.shortcode + " — " + p.likes + " likes"));

// fetch the next page (requires the cursor from a paginator or prior response)
pk
String
required
The numeric user ID of the account whose posts to fetch.
count
int
required
Number of posts to request in this page. Instagram may return fewer results than requested.
cursor
String
Pagination cursor (after) for fetching subsequent pages. Pass null to start at the most recent post.
ReturnsList<com.jxinsta.web.endpoints.post.PostData> ThrowsInstagramException

hashtagSearch(String tag, String after)

Returns a HashtagPaginator that pages through posts associated with a given hashtag. Each call to next() returns up to 29 HashtagPost records.
HashtagPaginator pager = PublicAPIs.hashtagSearch("travel", null);
while (pager.hasNext()) {
    List<HashtagPost> results = pager.next();
    results.forEach(hp -> System.out.println(hp.username() + ": " + hp.shortcode()));
}
tag
String
required
The hashtag to search for, without the # character (e.g. "travel" not "#travel").
after
String
Pagination cursor from a previous HashtagPaginator page. Pass null to start from the beginning.
Returnscom.jxinsta.web.paginators.HashtagPaginator

HashtagPost record

Each item yielded by HashtagPaginator.next() is a HashtagPost Java record with the following components.
shortcode
String
The shortcode of the post (the CODE part of instagram.com/p/CODE/).
id
String
The numeric media ID of the post.
caption
String
The post caption text.
username
String
The username of the account that published the post.
displayPicture
String
URL of the post’s display/thumbnail image (display_uri).
views
long
The view count of the post (play_count in the API response).
downloadUrl
String
Direct URL to the first video version of the post.