Skip to content

JxInsta

Rahil khan edited this page Mar 12, 2024 · 1 revision

This page is all about the main JxInsta class and its methods.

Login

You can either log in using your username-password or with cookies/bearer token.

Login with credentials

This will always create a new login session (which means that it will attempt to log in every time the code runs)

JxInsta instagram = new JxInsta("username","password",loginType);

Here, login type is one of, JxInsta.LoginType.WEB_AUTHENTICATION, LoginType.APP_AUTHENTICATION, LoginType.BOTH_APP_WEB_AUTHENTICATION.

Login with cookie/token

You would not like to log in every time users run your program. After login, you can cache that Instagram instance and can use it every time you create an Instagram object. See this example:

JxInsta insta = new JxInsta("cookie","bearer token");

This method will use the cookie or token for the authentication. This library will primarily use cookies for authorization, the token will only be used in the endpoint that does not work with cookies (strictly mobile).

Basic actions

Just use it like you use any object of the class to get or set data. It's very much similar and simple.

JxInsta  insta  =  new  JxInsta("cookie",  "bearer token");

List<Post>  posts  =  insta.getFeedPosts(10,  null);
List<Story[]>  stories  =  insta.getFeedStories();
Profile  profile  =  insta.getProfile("x0.rahil");

insta.uploadStory(new  File("path/to/photo"));
insta.postPicture(new  FileInputStream(new File("path/to/photo")),"caption",  false);

To see about the return classes, please check out the respective page of the documentation.

That's it

You have successfully learned to use Instagram programmatically. Now it's time to build amazing apps or bots using this library.

Clone this wiki locally