JxInsta is the primary entry point for the web module. It handles authentication, session management, and account-level actions such as posting media and searching for users. Every authenticated operation in the web module flows through an instance of this class.
Package
Public fields
The username of the authenticated account.
The password of the account. Only populated when the instance was created via the
JxInsta(username, password) constructor; null when created via getInstance.The
sessionid cookie value used to authenticate every request.The CSRF token attached to state-changing requests.
Constructor
JxInsta(String username, String password)
Logs into Instagram with the supplied credentials, performs the full browser-style login flow, and stores the resulting sessionid and CSRF token on the instance.
The Instagram username of the account to log into.
The plaintext password for the account. The library encodes it in the
#PWD_INSTAGRAM_BROWSER format before sending.java.io.IOException— if a network error occurs while making the login request.InstagramException— if Instagram rejects the credentials or returns an unexpected response. CheckgetReason()for the specific failure category (e.g.,INCORRECT_PASSWORD,CHECKPOINT_REQUIRED,TWO_FACTOR_REQUIRED).
Static factory
getInstance(String session, String crsf)
Creates a JxInsta instance from an existing, already-authenticated session. Use this to avoid logging in on every application start by persisting session and crsf between runs.
A valid
sessionid cookie value obtained from a previous login or from the browser’s developer tools.The CSRF token that pairs with the session.
JxInsta instance ready to make authenticated requests.
Methods
getProfile(String username)
Fetches the public and private profile information for any Instagram user by username. Returns a Profile object that also exposes action methods such as follow, block, and getPosts.
The Instagram username of the account to look up (without the
@ symbol).com.jxinsta.web.endpoints.profile.Profile
Throws — InstagramException
getFeedPosts(String cursor)
Returns a FeedPaginator that pages through the authenticated user’s home feed. Call next() to retrieve each batch of posts and hasNext() to check whether more pages remain.
Pagination cursor from a previous call. Pass
null to start from the beginning of the feed.com.jxinsta.web.paginators.FeedPaginator
getFeedStories()
Fetches all active stories visible in the authenticated user’s story tray. The return value is a list of arrays; each inner array holds all story frames for a single account.
List<Story[]>
Throws — InstagramException
postPicture(InputStream inputStream, String caption, boolean disableLikeAndComment)
Uploads a JPEG image and publishes it as a new Instagram post on the authenticated account.
A readable stream of the image data to upload.
The caption text for the new post.
When
true, likes and comments are disabled on the new post. Equivalent to toggling “Turn off commenting” in the app.void
Throws — java.io.IOException, InstagramException
getPost(String url)
Resolves a post URL to a Post object. Internally extracts the shortcode from the URL, converts it to a numeric media ID, and fetches full post data.
The full URL of the Instagram post, e.g.
https://www.instagram.com/p/CODE/.com.jxinsta.web.endpoints.post.Post
Throws — InstagramException
search(String username)
Searches Instagram for accounts whose usernames start with the given query string. Returns a map of username → profile picture URL for display in autocomplete or search UIs.
The username prefix to search for.
Map<String, String> where each key is a username and each value is that user’s profile picture URL.
Throws — InstagramException