Giter VIP home page Giter VIP logo

node-insta-web-api's Introduction

A Instagram Private Web API client 📷🔥 ❤️

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

Install

npm install node-insta-web-api

Usage

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

API Reference

getCookie()

await client.getCookie()

getting guest cookie

_getMediaId(url)

await client._getMediaId('https://www.instagram.com/p/CDFIAxxxxx/')

getting media id by url

  • url: A String

useExistingCookie()

await client.useExistingCookie()

u can use existing cookies, if you don't want to log in repeatedly

login(username, password)

await client.login('username', 'password')

Login.

  • username: A String
  • password: A String

getProfileData()

  //login required
  await InstaClient.login('username','password');
  const profileData = await InstaClient.getProfileData();
  console.log(profileData)

Getting profile data.

changeProfileImage(image)

  //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 : A String url / image path

updateProfile(params)

  const payload = {
      biography: 'test update bio 1',
      email: '[email protected]'
  }
  const a = await InstaClient.updateProfile(payload)
  console.log(a)

update profile. for now you can only update your bio.

  • params
    • biography: A String
    • email: A String

getImageByUser(params)

await client.getImageByUser('username')

Gets user photos.

  • username: A String

getVideoByShortCode(shortCode)

  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: A String

getLoginActivity()

  //login required
  await InstaClient.useExistingCookie()
  const data = await InstaClient.getLoginActivity();
  console.log(data)

get login activity.

getRecentNotification()

  //login required
  await InstaClient.useExistingCookie()
  const data = await InstaClient.getRecentNotification();
  console.log(data)

get recent notification.

getDirectMessage()

  //login required
  await InstaClient.useExistingCookie()
  const data = await InstaClient.getDirectMessage();
  console.log(data)

get direct message.

getProfileByUsername(username)

  await InstaClient.getCookie()
  const data = await InstaClient.getProfileByUsername('username');
  console.log(data)

get profile user.

  • username: A String

followByUsername(username)

  //login required
  await InstaClient.useExistingCookie()
  const data = await InstaClient.followByUsername('username');
  console.log(data)

follow user by username.

  • username: A String

unfollowByUsername(username)

  //login required
  await InstaClient.useExistingCookie()
  const data = await InstaClient.unfollowByUsername('username');
  console.log(data)

unfollow user by username.

  • username: A String

getStoriesByUsername(username)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.getStoriesByUsername('username');
  console.log(data)

get stories by username.

  • username: A String

likeMediaById(mediaId)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.likeMediaById(00000);
  console.log(data)

like media by media id

  • mediaId: A Number

likeMediaByShortCode(shortCode)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.likeMediaByShortCode('CDFIAQtHUxxxx');
  console.log(data)

like media by shortcode

  • shortCode: A String

unlikeMediaByShortCode(shortCode)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.unlikeMediaByShortCode('CDFIAQtHUxxxx');
  console.log(data)

unlike media by shortcode

  • shortCode: A String

deleteMediaByShortCode(shortCode)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.deleteMediaByShortCode('CDFIAQtHUxxxx');
  console.log(data)

delete media by shortcode

  • shortCode: A String

saveImageByShortCode(shortCode)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.saveImageByShortCode('CDFIAQtHUxxxx');
  console.log(data)

save media by shortcode

  • shortCode: A String

unsaveImageByShortCode(shortCode)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.unsaveImageByShortCode('CDFIAQtHUxxxx');
  console.log(data)

save media by shortcode

  • shortCode: A String

commentToMediaByMediaId(params)

  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

  • params
    • mediaId: A Number
    • commentText: A String

commentToMediaByShortCode(params)

  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

  • params
    • shortCode: A String
    • commentText: A String

replyCommentByShortCode(params)

  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

  • params
    • shortCode: A String
    • commentText: A String
    • commentId: A String

getEmbedMediaByShortCode(shortCode)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.getEmbedMediaByShortCode('CDFIAQtHUiw');
  console.log(data)

get embed media by shortCode

  • shortCode: A String

getMediaFeedByHashtag(name)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.getMediaFeedByHashtag('berita');
  console.log(data)

get post by hastag

  • name: A String

getUserPostById(userId)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.getUserPostById(00000);
  console.log(data)

get post by user id

  • userId: A Number

findPeopleByUserId(userid)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.findPeopleByUserId(00000);
  console.log(data)

find people by userid

  • userid: A Number

findPeopleByUsername(username)

  await InstaClient.useExistingCookie()
  const data = await InstaClient.findPeopleByUsername('menjadi');
  console.log(data)

find people by username

  • username: A String

addPost(image, caption)

  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: A String path of image
  • caption: A String

addStory(image)

  const photo = path.join(__dirname, '3.jpeg');
  await InstaClient.useExistingCookie();
  const resultAddStory = await InstaClient.addStory(photo);
  console.log(resultAddStory)

add story

  • image: A String path of image

getFollowingByDataUser(dataUser, size, cursor)

  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: A Object data user
  • size: A Number size per page
  • cursor: A String end cursor

getFollowersByDataUser(dataUser, size, 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: A Object data user
  • size: A Number size per page
  • cursor: A String end cursor

sendDmByUsername(username, password, usernameReceiver, message)

//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: A String username for login
  • password: A String password for login
  • usernameReceiver: A Array list username receiver message/dm
  • message: A String text message

sendConfirmationEmail()

 await InstaClient.useExistingCookie();
 const sendConfirmationEmailResult = await InstaClient.sendConfirmationEmail();
 console.log(sendConfirmationEmailResult)

License

MIT © Archv Id

node-insta-web-api's People

Contributors

cdw1p avatar dependabot[bot] avatar ihamdan991 avatar m1n007 avatar shinainaru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-insta-web-api's Issues

failed to uploading images

I use:
const result = await client.addPost(path.join(__dirname,imagePath), caption);

the image path is correct (i tried other ways too) but I get:
Failed to post to Instagram: Error: Error: failed to uploading images
at Instagram.addPost (D:\Web\socialagent\node_modules\node-insta-web-api\lib\index.js:693:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async postToInstagram (D:\Web\socialagent\app.js:47:24)
at async D:\Web\socialagent\app.js:28:4

Close Friends

Hi,
how to add and remove close friends using the api?

it's possible?

Error No Cookies When I try to login

I got the error no cookies when i try to login me..

Why?

await InstaClient.login('username,'password');
const profileData = await InstaClient.getProfileData();
console.log(profileData)

Direct Message

Hello everyone! How to send message on this API? Thank you :)

error when logging in

Error:

/root/bot/node_modules/node-insta-web-api/lib/index.js:149
            throw new Error(e)
                  ^

Error: Error: Login Failed, Please Try Again Later.
    at Instagram.login (/root/bot/node_modules/node-insta-web-api/lib/index.js:149:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async main (/root/bot/ninsta.js:5:3)

Node.js v19.1.0

My source code:

const Insta = require("node-insta-web-api")
const client = new Insta()

async function main() {
  await client.login("username", "password")

  console.log(await client.getProfileData())
}

main()

I have entered the username and password according to my Instagram account

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.