📷 Java client to Instagram's private API. Allows access to all the features that Instagram app provides.
Based on the Instagram PHP Api and Instagram Python Api.
Download the latest release JAR or grab via Maven:
<dependency>
<groupId>org.brunocvcunha.instagram4j</groupId>
<artifactId>instagram4j</artifactId>
<version>1.8</version>
</dependency>
or Gradle:
compile 'org.brunocvcunha.instagram4j:instagram4j:1.8'
// Login to instagram
Instagram4j instagram = Instagram4j.builder().username("username").password("password").build();
instagram.setup();
instagram.login();
InstagramSearchUsernameResult userResult = instagram.sendRequest(new InstagramSearchUsernameRequest("github"));
System.out.println("ID for @github is " + userResult.getUser().getPk());
System.out.println("Number of followers: " + userResult.getUser().getFollower_count());
instagram.sendRequest(new InstagramFollowRequest(userResult.getUser().getPk()));
instagram.sendRequest(new InstagramUnfollowRequest(userResult.getUser().getPk()));
InstagramGetUserFollowersResult githubFollowers = instagram.sendRequest(new InstagramGetUserFollowersRequest(userResult.getUser().getPk()));
List<InstagramUserSummary> users = githubFollowers.getUsers();
for (InstagramUserSummary user : users) {
System.out.println("User " + user.getUsername() + " follows Github!");
}
InstagramSearchUsernameResult userResult = instagram.sendRequest(new InstagramSearchUsernameRequest("github"));
System.out.println("ID for @github is " + userResult.getUser().getPk());
System.out.println("Number of followers: " + userResult.getUser().follower_count);
instagram.sendRequest(new InstagramUploadPhotoRequest(
new File("/tmp/file-to-upload.jpg"),
"Posted with Instagram4j, how cool is that?"));
instagram.sendRequest(new InstagramUploadVideoRequest(
new File("/tmp/file-to-upload.mp4"),
"Video posted with Instagram4j, how cool is that?"));
InstagramFeedResult tagFeed = instagram.sendRequest(new InstagramTagFeedRequest("github"));
for (InstagramFeedItem feedResult : tagFeed.getItems()) {
System.out.println("Post ID: " + feedResult.getPk());
}
instagram.sendRequest(new InstagramLikeRequest(feedResult.getPk()));
instagram.sendRequest(new iInstagramPostCommentRequest(feedResult.getPk(), "Hello! How are you?"));
InstagramGetMediaCommentsResult commentsResult = instagram.sendRequest(new InstagramGetMediaCommentsRequest(mediaId, maxCommentId));
recipients - List of recipients IDs (i.e. "1234567890")
instagram.sendRequest(InstagramDirectShareRequest.builder(ShareType.MESSAGE, recipients).message(message).build());
recipients - List of recipients IDs (i.e. "1234567890")
instagram.sendRequest(InstagramDirectShareRequest.builder(ShareType.MEDIA, recipients).mediaId(mid).message(message).build());
InstagramEditMediaRequest r = new InstagramEditMediaRequest(mediaId, caption);
UserTags tags = r.new UserTags();
tags.getTagsToAdd().add(r.new UserTag(userId, posX, posY));
tags.getTagsToAdd().add(r.new UserTag(userId2, posX2, posY2));
tags.getUserIdsToRemoveTag().add("1231231231");
tags.getUserIdsToRemoveTag().add("3213213213");
r.setUserTags(tags);
instagram.sendRequest(r);
git clone https://github.com/brunocvcunha/instagram4j
cd instagram4j
mvn clean install
Do you like this project? Support it by donating
Snapshots of the development version are available in Sonatype's snapshots
repository.
instagram4j requires at minimum Java 8.
- You will NOT use this API for marketing purposes (spam, botting, harassment, massive bulk messaging...).
- We do NOT give support to anyone who wants to use this API to send spam or commit other crimes.
- We reserve the right to block any user of this repository that does not meet these conditions.
This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by Instagram or any of its affiliates or subsidiaries. This is an independent and unofficial API. Use at your own risk.