-
Notifications
You must be signed in to change notification settings - Fork 8
Home
Rahil edited this page Apr 13, 2026
·
2 revisions
This documentation focuses on the mobile module (com.jxinsta.mobile). The web module shares ~99% of the design and the same examples below can be used as a guide for the web variant (package com.jxinsta.web) with minor API differences (session/csrf vs auth token).
Only concise, runnable-style examples for the mobile module are shown. Handle IOException and InstagramException where noted.
Quick notes
- Mobile class: com.jxinsta.mobile.JxInsta
- Many methods throw InstagramException (and some IOExceptions) — catch or propagate as needed.
- You can create an instance either by logging in (username/password) or by reusing an existing auth token.
import com.jxinsta.mobile.JxInsta;
import com.jxinsta.mobile.InstagramException;
try {
JxInsta insta = new JxInsta("USERNAME", "PASSWORD");
// use insta...
} catch (IOException | InstagramException e) {
e.printStackTrace();
}JxInsta insta = JxInsta.getInstance(AUTH_TOKEN);var profile = insta.getProfile("target_username"); // returns Profile
profile.follow();
System.out.println("bio: " + profile.bio);var feed = insta.getFeed(); // returns mobile FeedPaginator
// iterate using FeedPaginator API (see FeedPaginator class for methods)
while (feed.hasNext()) {
var page = feed.next();
page.items.forEach(item -> System.out.println(item.id));
}List<Story[]> stories = insta.getStories();
for (var userStories : stories) {
for (var s : userStories) {
System.out.println(s.username + " -> " + s.url);
}
}try (InputStream in = new FileInputStream("photo.jpg")) {
insta.postPicture(in, "Caption text", false); // false => likes/comments enabled
}var post = insta.getPost("https://www.instagram.com/p/SHORTCODE/");
System.out.println(post.caption);List<com.jxinsta.mobile.endpoints.profile.ProfileData> results = insta.search("query");
results.forEach(pd -> System.out.println(pd.username + " — " + pd.fullName));var inbox = insta.getDirectInbox(10, 5); // maxThreads, maxMessages
System.out.println("total threads: " + inbox.totalThreads);
if (!inbox.threads.isEmpty()) {
System.out.println("first thread recipient: " + inbox.threads.getFirst().recipient);
}Minimal tips
- Preserve AUTH_TOKEN between runs to avoid re-login; use JxInsta.getInstance(AUTH_TOKEN).
- postPicture requires a valid InputStream; ensure image format and size are acceptable.
- See FeedPaginator, Profile, Post, and Inbox classes for more detailed usage patterns.