Giter Site home page Giter Site logo

instagram4j's Introduction

instagram4j

Apache License Build Status Maven Central PRs Welcome

๐Ÿ“ท 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.

Usage

Download the latest release JAR or grab via Maven:

<dependency>
  <groupId>org.brunocvcunha.instagram4j</groupId>
  <artifactId>instagram4j</artifactId>
  <version>1.4</version>
</dependency>

or Gradle:

compile 'org.brunocvcunha.instagram4j:instagram4j:1.4'

Supported Operations & Examples

Login

// Login to instagram
Instagram4j instagram = Instagram4j.builder().username("username").password("password").build();
instagram.setup();
instagram.login();

Search user by handle

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());

Follow user

instagram.sendRequest(new InstagramFollowRequest(userResult.getUser().getPk()));

Unfollow user

instagram.sendRequest(new InstagramUnfollowRequest(userResult.getUser().getPk()));

Get user followers

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!");
}

Search user by handle

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);

Upload a photo your feed

instagram.sendRequest(new InstagramUploadPhotoRequest(
        new File("/tmp/file-to-upload.jpg"),
        "Posted with Instagram4j, how cool is that?"));

Upload a video your feed

instagram.sendRequest(new InstagramUploadVideoRequest(
        new File("/tmp/file-to-upload.mp4"),
        "Video posted with Instagram4j, how cool is that?"));

Get feed for a hashtag

InstagramFeedResult tagFeed = instagram.sendRequest(new InstagramTagFeedRequest("github"));
for (InstagramFeedItem feedResult : tagFeed.getItems()) {
    System.out.println("Post ID: " + feedResult.getPk());
}

Perform a like operation for a media

instagram.sendRequest(new InstagramLikeRequest(feedResult.getPk()));

Add a comment for a media

instagram.sendRequest(new iInstagramPostCommentRequest(feedResult.getPk(), "Hello! How are you?"));

Get comments from media

InstagramGetMediaCommentsResult commentsResult = instagram.sendRequest(new InstagramGetMediaCommentsRequest(mediaId, maxCommentId));

Share message

instagram.sendRequest(InstagramDirectShareRequest.builder(ShareType.MESSAGE, recipients).message(message).build());

Share media

instagram.sendRequest(InstagramDirectShareRequest.builder(ShareType.MEDIA, recipients).mediaId(mid).message(message).build());

Edit media

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);

(More operations to be added)

Building from the source

git clone https://github.com/brunocvcunha/instagram4j
cd instagram4j
mvn clean install

Do you like this project? Support it by donating

  • btc Bitcoin: 1GQT7r8p5CHT1VzN4nC9UAQy7HXexeTsFg

Snapshots of the development version are available in Sonatype's snapshots repository.

instagram4j requires at minimum Java 8.

Terms and conditions

  • 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.

Legal

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.

instagram4j's People

Contributors

bondarenkoevgeny avatar bvolpato avatar dennieljoshua avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.