Simple, easy implementation of the Instagram private web API.
Some API reference from jlobos/instagram-web-api
Send DM using client from dilame/instagram-private-api
npm install node-insta-web-api//send dm by username
const Insta = require('node-insta-web-api')
const InstaClient = new Insta();
(async () => {
  //required username & password for login
  const username = '';
  const password = '';
  const usernameReceiver = ['username target'];
  const message = 'text message';
  const result = await InstaClient.sendDmByUsername(username, password, usernameReceiver, message);
  console.log(result)
})()
//get profile data
const Insta = require('node-insta-web-api')
const InstaClient = new Insta();
(async () => {
    await InstaClient.login('username','password');
    const profileData = await InstaClient.getProfileData();
    console.log(profileData)
})()
//get image by username
const Insta = require('node-insta-web-api')
const InstaClient = new Insta();
(async () => {
   await Insta.getCookie()
   const photos = await Insta.getImageByUser('username');
   console.log(photos)
})()
//update bio using existing cookies
const Insta = require('node-insta-web-api')
const InstaClient = new Insta();
(async () => {
    await InstaClient.useExistingCookie()
    const payload = {
        biography: 'test update bio 1'
    }
    const result = await InstaClient.updateProfile(payload)
    console.log(result)
})()
//get following with pagination using existing cookie
await InstaClient.useExistingCookie();
const dataUser = await InstaClient.getProfileByUsername('amin_udin69');
let following;
let hasNextPage;
let endCursor = '';
const resultAllFollowing = [];
do{
    following = await InstaClient.getFollowingByDataUser(dataUser, 12, endCursor);
    hasNextPage = following.page_info.has_next_page;
    endCursor = following.page_info.end_cursor;
    for (let index = 0; index < following.edges.length; index++) {
        const element = following.edges[index];
        resultAllFollowing.push(element.node)
        
    }
}while(hasNextPage);
console.log(resultAllFollowing)
- Instagram
- .getCookie()
 - ._getMediaId(url)
 - .useExistingCookie()
 - .login(username, password)
 - .getProfileData()
 - .changeProfileImage(image)
 - .getImageByUser(username)
 - .getVideoByShortCode(shortCode)
 - .getLoginActivity()
 - .getRecentNotification()
 - .getDirectMessage()
 - .getProfileByUsername(username)
 - .followByUsername(username)
 - .unfollowByUsername(username)
 - .getStoriesByUsername(username)
 - .likeMediaById(mediaId)
 - .likeMediaByShortCode(shortCode)
 - .unlikeMediaByShortCode(shortCode)
 - .deleteMediaByShortCode(shortCode)
 - .saveImageByShortCode(shortCode)
 - .unsaveImageByShortCode(shortCode)
 - .commentToMediaByMediaId({shortCode, commentText})
 - .commentToMediaByShortCode({shortCode, commentText})
 - .replyCommentByShortCode({shortCode, commentText, commentId})
 - .getEmbedMediaByShortCode(shortCode)
 - .getMediaFeedByHashtag(name)
 - .getUserPostById(userId)
 - .findPeopleByUserId(userid)
 - .findPeopleByUsername(username)
 - .addPost(image, caption)
 - .addStory(image)
 - .getFollowingByDataUser(dataUser, size, cursor)
 - .getFollowersByDataUser(dataUser, size, cursor)
 - .sendDmByUsername(username, password, usernameReceiver, message)
 - .sendConfirmationEmail()
 
 
await client.getCookie()getting guest cookie
await client._getMediaId('https://www.instagram.com/p/CDFIAxxxxx/')getting media id by url
url: AString
await client.useExistingCookie()u can use existing cookies, if you don't want to log in repeatedly
await client.login('username', 'password')Login.
username: AStringpassword: AString
  //login required
  await InstaClient.login('username','password');
  const profileData = await InstaClient.getProfileData();
  console.log(profileData)Getting profile data.
  //login required
  //using a url is under development
  //by url
  await InstaClient.login('username','password');
  await InstaClient.changeProfileImage('url')
  //by path
  await InstaClient.login('username','password');
  const photo = path.join(__dirname, 'blackhat.png');
  await InstaClient.changeProfileImage(photo)Change Profile Image.
image: AStringurl / image path
  const payload = {
      biography: 'test update bio 1',
      email: 'update@email.com'
  }
  const a = await InstaClient.updateProfile(payload)
  console.log(a)update profile. for now you can only update your bio.
paramsbiography: AStringemail: AString
await client.getImageByUser('username')Gets user photos.
username: AString
  const data = await InstaClient.getVideoByShortCode('CDDs8unBjXX');
  fs.writeFileSync('./test.mp4', data.base64, 'base64')
  console.log(data)Get video base64 and buffer by short code.
shortCode: AString
  //login required
  await InstaClient.useExistingCookie()
  const data = await InstaClient.getLoginActivity();
  console.log(data)get login activity.
  //login required
  await InstaClient.useExistingCookie()
  const data = await InstaClient.getRecentNotification();
  console.log(data)get recent notification.
  //login required
  await InstaClient.useExistingCookie()
  const data = await InstaClient.getDirectMessage();
  console.log(data)get direct message.
  await InstaClient.getCookie()
  const data = await InstaClient.getProfileByUsername('username');
  console.log(data)get profile user.
username: AString
  //login required
  await InstaClient.useExistingCookie()
  const data = await InstaClient.followByUsername('username');
  console.log(data)follow user by username.
username: AString
  //login required
  await InstaClient.useExistingCookie()
  const data = await InstaClient.unfollowByUsername('username');
  console.log(data)unfollow user by username.
username: AString
  await InstaClient.useExistingCookie()
  const data = await InstaClient.getStoriesByUsername('username');
  console.log(data)get stories by username.
username: AString
  await InstaClient.useExistingCookie()
  const data = await InstaClient.likeMediaById(00000);
  console.log(data)like media by media id
mediaId: ANumber
  await InstaClient.useExistingCookie()
  const data = await InstaClient.likeMediaByShortCode('CDFIAQtHUxxxx');
  console.log(data)like media by shortcode
shortCode: AString
  await InstaClient.useExistingCookie()
  const data = await InstaClient.unlikeMediaByShortCode('CDFIAQtHUxxxx');
  console.log(data)unlike media by shortcode
shortCode: AString
  await InstaClient.useExistingCookie()
  const data = await InstaClient.deleteMediaByShortCode('CDFIAQtHUxxxx');
  console.log(data)delete media by shortcode
shortCode: AString
  await InstaClient.useExistingCookie()
  const data = await InstaClient.saveImageByShortCode('CDFIAQtHUxxxx');
  console.log(data)save media by shortcode
shortCode: AString
  await InstaClient.useExistingCookie()
  const data = await InstaClient.unsaveImageByShortCode('CDFIAQtHUxxxx');
  console.log(data)save media by shortcode
shortCode: AString
  await InstaClient.useExistingCookie()
  const payload = {
      mediaId: 100000,
      commentText: 'Your Text Comment'
  }
  const data = await InstaClient.commentToMediaByMediaId(payload);
  console.log(data)add comment to a media by shortcode
paramsmediaId: ANumbercommentText: AString
  await InstaClient.useExistingCookie()
  const payload = {
      shortCode:'CDFIAQxxxx',
      commentText: 'Your Text Comment'
  }
  const data = await InstaClient.commentToMediaByShortCode(payload);
  console.log(data)add comment to a media by shortcode
paramsshortCode: AStringcommentText: AString
  await InstaClient.useExistingCookie()
  const payload = {
      shortCode:'CDFIAQtxxxx',
      commentText: '%40username reply comment',
      commentId: '17870873200867xxx'
  }
  const data = await InstaClient.replyCommentByShortCode(payload);
  console.log(data)reply comment in media by shortcode
paramsshortCode: AStringcommentText: AStringcommentId: AString
  await InstaClient.useExistingCookie()
  const data = await InstaClient.getEmbedMediaByShortCode('CDFIAQtHUiw');
  console.log(data)get embed media by shortCode
shortCode: AString
  await InstaClient.useExistingCookie()
  const data = await InstaClient.getMediaFeedByHashtag('berita');
  console.log(data)get post by hastag
name: AString
  await InstaClient.useExistingCookie()
  const data = await InstaClient.getUserPostById(00000);
  console.log(data)get post by user id
userId: ANumber
  await InstaClient.useExistingCookie()
  const data = await InstaClient.findPeopleByUserId(00000);
  console.log(data)find people by userid
userid: ANumber
  await InstaClient.useExistingCookie()
  const data = await InstaClient.findPeopleByUsername('menjadi');
  console.log(data)find people by username
username: AString
  const photo = path.join(__dirname, '3.jpeg');
  await InstaClient.useExistingCookie();
  const resultAddPost = await InstaClient.addPost(photo, 'this is caption');
  console.log(resultAddPost)add post to feed
image: AStringpath of imagecaption: AString
  const photo = path.join(__dirname, '3.jpeg');
  await InstaClient.useExistingCookie();
  const resultAddStory = await InstaClient.addStory(photo);
  console.log(resultAddStory)add story
image: AStringpath of image
  await InstaClient.useExistingCookie();
  const dataUser = await InstaClient.getProfileByUsername('amin_udin69');
  let following;
  let hasNextPage;
  let endCursor = '';
  const resultAllFollowing = [];
  do{
      following = await InstaClient.getFollowingByDataUser(dataUser, 12, endCursor);
      hasNextPage = following.page_info.has_next_page;
      endCursor = following.page_info.end_cursor;
      for (let index = 0; index < following.edges.length; index++) {
          const element = following.edges[index];
          resultAllFollowing.push(element.node)
          
      }
  }while(hasNextPage);
  console.log(resultAllFollowing)get following by data user
dataUser: AObjectdata usersize: ANumbersize per pagecursor: AStringend cursor
  await InstaClient.useExistingCookie();
  const dataUser = await InstaClient.getProfileByUsername('amin_udin69');
  let followers;
  let hasNextPage;
  let endCursor = '';
  const resultAllFollowers = [];
  do{
      followers = await InstaClient.getFollowersByDataUser(dataUser, 12, endCursor);
      hasNextPage = followers.page_info.has_next_page;
      endCursor = followers.page_info.end_cursor;
      for (let i = 0; i < followers.edges.length; i++) {
          const element = followers.edges[i];
          resultAllFollowers.push(element.node)
          
      }
  }while(hasNextPage);
  console.log(resultAllFollowers)get followers by data user
dataUser: AObjectdata usersize: ANumbersize per pagecursor: AStringend cursor
//login required
  const username = ''; //required
  const password = ''; //required
  const usernameReceiver = ['username target'];
  const message = 'text message';
  const result = await InstaClient.sendDmByUsername(username, password, usernameReceiver, message);
  console.log(result)send dm
username: AStringusername for loginpassword: AStringpassword for loginusernameReceiver: AArraylist username receiver message/dmmessage: AStringtext message
 await InstaClient.useExistingCookie();
 const sendConfirmationEmailResult = await InstaClient.sendConfirmationEmail();
 console.log(sendConfirmationEmailResult)MIT © Archv Id