{"id":15029205,"url":"https://github.com/jlobos/instagram-web-api","last_synced_at":"2025-05-14T23:07:02.785Z","repository":{"id":37451961,"uuid":"109791547","full_name":"jlobos/instagram-web-api","owner":"jlobos","description":"🤳 Instagram Private Web API client for Node","archived":false,"fork":false,"pushed_at":"2024-07-28T09:58:04.000Z","size":592,"stargazers_count":1138,"open_issues_count":172,"forks_count":187,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-05-13T17:49:52.286Z","etag":null,"topics":["api","client","comment","instagram","like","love","node","photo","private","upload"],"latest_commit_sha":null,"homepage":"https://npmjs.com/instagram-web-api","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jlobos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-07T05:38:34.000Z","updated_at":"2025-05-10T08:25:12.000Z","dependencies_parsed_at":"2024-06-18T12:34:05.917Z","dependency_job_id":"803fe629-6f7d-481f-8ffa-fd60fb0049e4","html_url":"https://github.com/jlobos/instagram-web-api","commit_stats":{"total_commits":78,"total_committers":21,"mean_commits":"3.7142857142857144","dds":0.717948717948718,"last_synced_commit":"e85a0f603e5be9e147606feed73a5057d74c5c60"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlobos%2Finstagram-web-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlobos%2Finstagram-web-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlobos%2Finstagram-web-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlobos%2Finstagram-web-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jlobos","download_url":"https://codeload.github.com/jlobos/instagram-web-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243362,"owners_count":22038046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","client","comment","instagram","like","love","node","photo","private","upload"],"created_at":"2024-09-24T20:09:57.557Z","updated_at":"2025-05-14T23:06:57.772Z","avatar_url":"https://github.com/jlobos.png","language":"JavaScript","readme":"\u003ch1 align=\"center\"\u003e\n  \u003cimg width=\"72px\" src=\"https://firebasestorage.googleapis.com/v0/b/random-storage-332ce.appspot.com/o/instagram.svg?alt=media\u0026token=5fe11096-daee-43c1-8d5f-8a77c9f46485\"\u003e\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/instagram-web-api\"\u003e\u003cimg alt=\"NPM version\" src=\"https://badge.fury.io/js/instagram-web-api.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://circleci.com/gh/jlobos/instagram-web-api\"\u003e\u003cimg alt=\"Build Status\" src=\"https://circleci.com/gh/jlobos/instagram-web-api.svg?style=shield\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/sindresorhus/xo\"\u003e\u003cimg alt=\"XO code style\" src=\"https://img.shields.io/badge/code_style-XO-5ed9c7.svg\"\u003e\u003c/a\u003e\n  \n\u003c/p\u003e\n\n### A Instagram Private Web API client 🤳✨❤️\n\nSimple, easy and very complete implementation of the Instagram private web API.\n\n- Support for all the main functions of [Instagram Web](https://www.instagram.com/)\n- Well tested, CI\n- All test runs daily\n\n## Install\n\n```bash\nnpm install instagram-web-api\n```\n\n## Usage\n\nIntance `Instagram` and call `login` method; this stores the credentials in memory.\n\n```js\nconst Instagram = require('instagram-web-api')\nconst { username, password } = process.env\n\nconst client = new Instagram({ username, password })\n\nclient\n  .login()\n  .then(() =\u003e {\n    client\n      .getProfile()\n      .then(console.log)\n  })\n```\n\nUsing `async`/`await` in Node \u003e= 8\n\n```js\nconst Instagram = require('instagram-web-api')\nconst { username, password } = process.env\n\nconst client = new Instagram({ username, password })\n\n;(async () =\u003e {\n  await client.login()\n  const profile = await client.getProfile()\n\n  console.log(profile)\n})()\n```\n\nSave cookies to disk by using a `though-cookie` store.\n\n```js\n// Packages\nconst Instagram = require('instagram-web-api')\nconst FileCookieStore = require('tough-cookie-filestore2')\n\nconst { username, password } = process.env // Only required when no cookies are stored yet\n\nconst cookieStore = new FileCookieStore('./cookies.json')\nconst client = new Instagram({ username, password, cookieStore })\n\n;(async () =\u003e {\n  // URL or path of photo\n  const photo =\n    'https://scontent-scl1-1.cdninstagram.com/t51.2885-15/e35/22430378_307692683052790_5667315385519570944_n.jpg'\n\n  await client.login()\n\n  // Upload Photo to feed or story, just configure 'post' to 'feed' or 'story'\n  const { media } = await client.uploadPhoto({ photo: photo, caption: 'testing', post: 'feed' })\n  console.log(`https://www.instagram.com/p/${media.code}/`)\n})()\n```\n\n## API Reference\n\n* [Instagram](#instagramcredentials-opts)\n  * [new Instagram({ username, password, cookieStore }, { language, proxy, requestOptions })](#instagramcredentials-opts)\n  * [.login({ username, password })](#logincredentials)\n  * [.logout()](#logout)\n  * [.getHome()](#gethome)\n  * [.getUserByUsername({ username })](#getuserbyusernameparams)\n  * [.getFollowers({ userId, first, after })](#getfollowersparams)\n  * [.getFollowings({ userId, first, after })](#getfollowingsparams)\n  * [.getActivity()](#getactivity)\n  * [.getProfile()](#getprofile)\n  * [.updateProfile({ name, email, username, phoneNumber, gender, biography, website, similarAccountSuggestions })](#updateprofileparams)\n  * [.changeProfilePhoto({ photo })](#changeprofilephotoparams)\n  * [.deleteMedia({ mediaId })](#deletemediaparams)\n  * [.uploadPhoto({ photo, caption, post })](#uploadphotoparams)\n  * [.getMediaFeedByLocation({ locationId })](#getmediafeedbylocationparams)\n  * [.getMediaFeedByHashtag({ hashtag })](#getmediafeedbyhashtagparams)\n  * [.locationSearch({ query, latitude, longitude })](#locationsearchparams)\n  * [.getMediaByShortcode({ shortcode })](#getmediabyshortcodeparams)\n  * [.addComment({ mediaId, text })](#addcommentparams)\n  * [.deleteComment({ mediaId, commentId })](#deletecommentparams)\n  * [.getChallenge({ challengeUrl })](#getchallengeparams)\n  * [.updateChallenge({ challengeUrl, choice, securityCode })](#updatechallengeparams)\n  * [.resetChallenge({ challengeUrl })](#resetchallengeparams)\n  * [.replayChallenge({ challengeUrl })](#replaychallengeparams)\n  * [.approve({ userId })](#approveparams)\n  * [.ignore({ userId })](#ignoreparams)\n  * [.follow({ userId })](#followparams)\n  * [.unfollow({ userId })](#unfollowparams)\n  * [.block({ userId })](#blockparams)\n  * [.unblock({ userId })](#unblockparams)\n  * [.like({ mediaId })](#likeparams)\n  * [.unlike({ mediaId })](#unlikeparams)\n  * [.save({ mediaId })](#saveparams)\n  * [.unsave({ mediaId })](#unsaveparams)\n  * [.search({ query, context })](#searchparams)\n  * [.getPhotosByHashtag({hashtag, first, after})](#gethastagphotosparams)\n  * [.getPhotosByUsername({username, first, after})](#getphotosbyusernameparams)\n  * [.getPrivateProfilesFollowRequests(cursor)](#getPrivateProfilesFollowRequests)\n  * [.getChainsData({ userId })](#getChainsData)\n  * [.getMediaLikes({ shortcode, first, after })](#getMediaLikesParams)\n  * [.getMediaComments({ shortcode, first, after })](#getMediaCommentsParams)\n\n### Instagram(credentials, opts)\n```js\nconst client = new Instagram({ username: '', password: '' }, { language: 'es-CL' })\n```\n\u003e Initializes the client.\n- `credentials`\n  - `username`: The username of account\n  - `password`: The password of account\n  - `cookieStore`: An optional [`though-cookie`](https://www.npmjs.com/package/tough-cookie) cookie storage, which allows for persistent cookies. Default is `undefined`\n- `opts`\n  - `language`: The language of response from API. Default is `en-US`\n  - `proxy`: `String` of a proxy to tunnel all requests. Default is `undefined` \n\n### login(credentials)\n```js\nconst { username, password, cookies } = await client.login({ username: '', password: '' })\nconst { authenticated, user } = await client.login({ username: '', password: '' })\n```\n\n\u003e Login in the account, this method returns `user` (`true` when username is valid) and `authenticated` (`true` when login was successful)\n- `credentials`\n  - `username`: The username of account\n  - `password`: The password of account\n\n### logout()\n```js\nawait client.logout()\n```\n\u003e Logout in the account.\n\n### getHome()\n```js\nconst feed = await client.getHome('KGEAxpEdUwUrxxoJvxRoQeXFGooSlADHZ8UaDdSWbnOIxxoUUhyciJ7EGlxNlZjaYcUaXTgUM00qyBrgBhUsLezIGqVTlxqausga5W-fVax9xRryaBdN1EnIGvdQFgzxoMgaFoLO7v7xWQA=')\n```\n\u003e Get home feed timeline, media shared by the people you follow.\n- `params`\n  - `end_cursor` (`String`) for pagination\n\n### getUserByUsername(params)\n```js\nconst instagram = await client.getUserByUsername({ username: 'instagram' })\nconst me = await client.getUserByUsername({ username: client.credentials.username })\n```\n\u003e Get user by username, this method not require authentication for public profiles.\n- `params`\n  - `username`: The username of the profile\n\n### getFollowers(params)\n```js\nconst followers = await client.getFollowers({ userId: '1284161654' })\n```\n\u003e Get followers for given userId. Be aware that the response gets slightly altered for easier usage.\n- `params`\n  - `userId`: The user id\n  - `first`: Amount of followers to request. Default is `20`\n  - `after`: Optional `end_cursor` (`String`) for pagination.\n\n### getFollowings(params)\n```js\nconst followings = await client.getFollowings({ userId: '1284161654' })\n```\n\u003e Get followings for given userId. Be aware that the response gets slightly altered for easier usage.\n- `params`\n  - `userId`: The user id\n  - `first`: Amount of followings to request. Default is `20`\n  - `after`: Optional `end_cursor` (`String`) for pagination. \n\n### getActivity()\n```js\nconst activity = await client.getActivity()\n```\n\u003e Get activity of account, news following, liked, etc.\n\n### getProfile()\n```js\nconst profile = await client.getProfile()\n```\n\u003e Get profile the account `first_name`, `last_name`, `email`, `username`, `phone_number`, `gender`, `birthday`, `biography`, `external_url` and `chaining_enabled`.\n\n### updateProfile(params)\n```js\nawait client.updateProfile({ biography: '❤️', website: 'https://jlobos.com/', gender: 1 })\n```\n\u003e Update profile the account.\n- `params`\n  - `name`: The full name. Default is ` `\n  - `email`: The email of account. Default is ` `\n  - `username`: The username of account. Default is `client.credentials.username`\n  - `phoneNumber`: The Phone Number. Default is ` `\n  - `gender`: `Number` `1` male, `2` female and `3` not specified\n  - `biography`: The Bio. Default is ` `\n  - `website`: The Website. Default is ` `\n  - `similarAccountSuggestions`: `Boolean` Include your account when recommending similar accounts people might want to follow. Default is `true`\n\n### changeProfilePhoto(params)\n```js\nconst fs = require('fs')\n\nconst photo = fs.join(__dirname, 'photo.jpg')\nawait client.changeProfilePhoto({ photo })\n```\n\u003e Change the profile photo.\n- `params`\n  - `photo`: A `String` of path file or URL\n\n### deleteMedia(params)\n```js\nawait client.deleteMedia({ mediaId: '1442533050805297981' })\n```\n\u003e Delete a media, photo, video, etc. by the id.\n- `params`\n  - `mediaId`: The media id\n\n### uploadPhoto(params)\n```js\nconst photo = 'https://scontent-scl1-1.cdninstagram.com/t51.2885-15/e35/16465198_658888867648924_4042368904838774784_n.jpg'\nawait client.uploadPhoto({ photo, caption: '❤️', post: 'feed' })\n```\n\u003e Upload a photo to Instagram. Only jpeg images allowed.\n- `params`\n  - `photo`: A `String` of path file or URL\n  - `caption`: The caption of photo. Default is ` `\n  - `post`: The local post, `feed` or `story`\n\n### getMediaFeedByLocation(params)\n```js\nconst location = await client.getMediaFeedByLocation({ locationId: '26914683' })\n```\n\u003e Get latitude, longitude, top posts, last media, country, city, and more related to the location.\n- `params`\n  - `locationId`: The location id\n\n### getMediaFeedByHashtag(params)\n```js\nconst tag = client.getMediaFeedByHashtag({ hashtag: 'unicorn' })\n```\n\u003e Explore last media and top posts feed related to a hashtag.\n- `params`\n  - `hashtag`: A hashtag, not including the \"#\"\n\n### locationSearch(params)\n```js\nconst venues = client.locationSearch({ query: 'chile', latitude: -33.45, longitude: -70.6667 })\n```\n\u003e Search venues by latitude and longitude.\n- `params`\n  - `latitude`: Latitude\n  - `longitude`: Longitude\n  - `query`: A optional location name. Default is ` `\n\n### getMediaByShortcode(params)\n```js\nconst media = await client.getMediaByShortcode({ shortcode: 'BQE6Cq2AqM9' })\n```\n\u003e Get data of a media by the Instagram shortcode\n- `params`\n  - `shortcode`: A shortcode\n\n### addComment(params)\n```js\nawait client.addComment({ mediaId: 1442533050805297981, text: 'awesome' })\n```\n\u003e Add comment to a media item.\n- `params`\n  - `mediaId`: The media id\n  - `text`: Comment text\n  - `replyToCommentId`: Optional comment id to which to reply\n\n### deleteComment(params)\n```js\nawait client.deleteComment({ mediaId: '1442533050805297981', commentId: '17848908229146688' })\n```\n\u003e Delete a comment.\n- `params`\n  - `mediaId`: The media id\n  - `commentId`: The comment id\n\n### getChallenge(params)\n```js\nawait client.getChallenge({ challengeUrl: '/challenge/1284161654/a1B2c3d4E6/' })\n```\n\u003e Get information about a challenge.\n- `params`\n  - `challengeUrl`: A `String` with a challenge path\n\n### updateChallenge(params)\n```js\nconst challengeUrl = '/challenge/1284161654/a1B2c3d4E6/'\n\nawait client.updateChallenge({ challengeUrl, choice: 0 })\nawait client.updateChallenge({ challengeUrl, securityCode: 123456  })\n```\n\u003e Request or submit a verification code for the given challenge.\n- `params`\n  - `challengeUrl`: A `String` with a challenge path\n  - `choice`: `Number` `0` for phone and `1` for email. Default is ``\n  - `securityCode`: `Number` the received verification code for the challenge. Default is ``\n\n### resetChallenge(params)\n```js\nawait client.resetChallenge({ challengeUrl: '/challenge/1284161654/a1B2c3d4E6/' })\n```\n\u003e Reset a challenge to start over again.\n- `params`\n  - `challengeUrl`: A `String` with a challenge path\n\n### replayChallenge(params)\n```js\nawait client.replayChallenge({ challengeUrl: '/challenge/1284161654/a1B2c3d4E6/' })\n```\n\u003e Request a new verification message.\n- `params`\n  - `challengeUrl`: A `String` with a challenge path\n\n### approve(params)\n```js\nawait client.approve({ userId: '1284161654' })\n```\n\u003e Approve a friendship request.\n- `params`\n  - `userId`: The user id\n\n### ignore(params)\n```js\nawait client.ignore({ userId: '1284161654' })\n```\n\u003e Reject a friendship request.\n- `params`\n  - `userId`: The user id\n\n### follow(params)\n```js\nawait client.follow({ userId: '1284161654' })\n```\n\u003e Follow a user.\n- `params`\n  - `userId`: The user id\n\n### unfollow(params)\n```js\nawait client.unfollow({ userId: '1284161654' })\n```\n\u003e Unfollow a user.\n- `params`\n  - `userId`: The user id\n\n### block(params)\n```js\nawait client.block({ userId: '1284161654' })\n```\n\u003e Block a user.\n- `params`\n  - `userId`: The user id\n\n### unblock(params)\n```js\nawait client.unblock({ userId: '1284161654' })\n```\n\u003e Unblock a user.\n- `params`\n  - `userId`: The user id\n\n### like(params)\n```js\nawait client.like({ mediaId: '1442533050805297981' })\n```\n\u003e Like a media item.\n- `params`\n  - `mediaId`: The media id\n\n### unlike(params)\n```js\nawait client.unlike({ mediaId: '1442533050805297981' })\n```\n\u003e Unlike a media item.\n- `params`\n  - `mediaId`: The media id\n\n### save(params)\n```js\nawait client.save({ mediaId: '1442533050805297981' })\n```\n\u003e Save a media item.\n- `params`\n  - `mediaId`: The media id\n\n### unsave(params)\n```js\nawait client.unsave({ mediaId: '1442533050805297981' })\n```\n\u003e Unsave a media item.\n- `params`\n  - `mediaId`: The media id\n\n### search(params)\n```js\nawait client.search({ query: 'unicorn' })\n```\n\u003e Search users, places, or hashtags.\n- `params`\n  - `query`: Query\n  - `context`: The context of search, `hashtag`, `place`, `user` or `blended`. Default is `blended`\n  \n  \n  \n### getPhotosByHashtag(params)\n```js\nawait client.getPhotosByHashtag({ hashtag: 'unicorn' })\n```\n\u003e Get photos for hashtag.\n- `params`\n  - `hashtag`: A `String` with a hashtag\n  - `first`:  A `number` of records to return\n  - `after`: The query cursor `String` for pagination\n  \n### getPhotosByUsername(params)\n  ```js\n  await client.getPhotosByUsername({ username: 'unicorn' })\n  ```\n  \u003e Gets user photos.\n  - `params`\n    - `username`: A `String` with a hashtag\n    - `first`:  A `number` of records to return\n    - `after`: The query cursor `String` for pagination\n\n### getPrivateProfilesFollowRequests\n  ```js\n  await client.getPrivateProfilesFollowRequests(cursor)\n  ```\n\n### getChainsData\n  ```js\n  await client.getChainsData({ userId })\n  ```\n  \u003e This will return the similar accounts, that you see, when you click on the ARROW in a profile.\n- `params`\n  - `userId`: The user id\n  \n### getMediaLikes(params)\n  ```js\n  await client.getMediaLikes({ shortcode: 'B-0000000', first: '49', after: '' })\n  ```\n  \u003e This will return the media likes.\n  - `params`\n    - `shortcode`: The shortcode media like this: https://www.instagram.com/p/B-00000000/, only put shortcode like this : B-000000000\n    - `first`:  A `number` of records to return max is `49`\n    - `after`: The query cursor `String` for pagination\n\n### getMediaComments(params)\n  ```js\n  await client.getMediaComments({ shortcode: 'B-0000000', first: '12', after: '' }).catch((error) =\u003e {\n    console.log(error);\n  })\n  .then((response) =\u003e {\n    console.log(response);\n  });\n  \n  //The query cursor 'after' maybe return an array, if array you need to convert like this: \n  let pointer = response.page_info.end_cursor;\n  // this will try to convert array to json stringify\n\ttry{\n\t\t\tpointer = JSON.parse(pointer);\n\t\t\tpointer = JSON.stringify(pointer);\n\t}catch(e){\n\t\t\tconsole.log('Pointer is not array!, don't need to be converted!');\n\t}\n  \n  ```\n  \u003e This will return the media comments.\n  - `params`\n    - `shortcode`: The shortcode media like this: https://www.instagram.com/p/B-00000000/, only put shortcode like this : B-000000000\n    - `first`:  A `number` of records to return max is `49`\n    - `after`: The query cursor `String` for pagination\n\n## License\n\nMIT © [Jesús Lobos](https://jlobos.com/)\n","funding_links":[],"categories":["Social Media","JavaScript"],"sub_categories":["Images"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlobos%2Finstagram-web-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjlobos%2Finstagram-web-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlobos%2Finstagram-web-api/lists"}