{"id":23139556,"url":"https://github.com/ezzcodeezzlife/scraper-instagram","last_synced_at":"2025-08-17T11:33:37.364Z","repository":{"id":40375696,"uuid":"478967976","full_name":"ezzcodeezzlife/scraper-instagram","owner":"ezzcodeezzlife","description":"Scrape data from Instagram without applying for the authenticated API 🎯","archived":false,"fork":false,"pushed_at":"2022-07-27T10:54:20.000Z","size":85,"stargazers_count":13,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2023-03-04T19:55:37.327Z","etag":null,"topics":["auth","authentication","crawler","ig","instagram","instagram-api","instagram-client","instagram-scraper","javascript","js","nodejs","npm","scraper","scraper-instagram","scraping","wrapper"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/scraper-instagram","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ezzcodeezzlife.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}},"created_at":"2022-04-07T12:08:30.000Z","updated_at":"2023-01-31T19:43:36.000Z","dependencies_parsed_at":"2022-08-02T01:09:36.640Z","dependency_job_id":null,"html_url":"https://github.com/ezzcodeezzlife/scraper-instagram","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezzcodeezzlife%2Fscraper-instagram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezzcodeezzlife%2Fscraper-instagram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezzcodeezzlife%2Fscraper-instagram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezzcodeezzlife%2Fscraper-instagram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ezzcodeezzlife","download_url":"https://codeload.github.com/ezzcodeezzlife/scraper-instagram/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230121616,"owners_count":18176477,"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":["auth","authentication","crawler","ig","instagram","instagram-api","instagram-client","instagram-scraper","javascript","js","nodejs","npm","scraper","scraper-instagram","scraping","wrapper"],"created_at":"2024-12-17T13:14:27.017Z","updated_at":"2024-12-17T13:14:27.088Z","avatar_url":"https://github.com/ezzcodeezzlife.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![logo](https://github.com/ezzcodeezzlife/scraper-instagram/blob/main/logo.png)\n# scraper-instagram\n\nScrape data from Instagram without applying for the authenticated API.\n\n## Getting started\n\n### Prerequisites\n\n- NodeJS\n- NPM or Yarn\n\n### Install\n\nFrom [npm](https://www.npmjs.com/package/scraper-instagram)\n\n`npm i scraper-instagram --save`\n\nor \n\n`yarn add scraper-instagram`\n\n\n\n### Basic usage\n\n```js\nconst Insta = require('scraper-instagram');\nconst InstaClient = new Insta();\n\nInstaClient.getHashtag(\"javascript\")\n    .then((hashtag) =\u003e console.log(hashtag))\n    .catch((err) =\u003e console.error(err));\n```\n\n```\n...\n{\n\tshortcode: 'CbGxIdAXxA',\n\tcaption: 'Lorem ipsum #javascript',\n\tcomments: 66,\n\tlikes: 1090,\n\tthumbnail: 'https://scontent-dus1-1.cdninstagram.com/v/123',\n\ttimestamp: 1647290186\n},\n...\n``` \n\n# Authentication\n\nAuthentication allows you to access private profile as long as you follow them.\n\n##### Importing your session ID\n\n- Go to instagram.com\n- Login *(if not already logged in)*\n- Open development tools *(`Ctrl` + `Shift` + `I`)*\n- Get the `sessionid` cookie value\n\t- For chromium-based browsers : `application` tab\n\t- For firefox-based browsers : `storage` tab\n\n##### Code\n\n```js\nInstaClient.authBySessionId(yourSessionId)\n\t.then(account =\u003e console.log(account))\n\t.catch(err =\u003e console.error(err));\n```\n\nIf authentication is successfull, you'll get the form data from `accounts/edit` :\n\n```json\n{\n\t\"first_name\": \"\",\n\t\"last_name\": \"\",\n\t\"email\": \"\",\n\t\"is_email_confirmed\": true,\n\t\"is_phone_confirmed\": true,\n\t\"username\": \"\",\n\t\"phone_number\": \"\",\n\t\"gender\": 1,\n\t\"birthday\": null,\n\t\"biography\": \"\",\n\t\"external_url\": \"\",\n\t\"chaining_enabled\": true,\n\t\"presence_disabled\": false,\n\t\"business_account\": false,\n\t\"usertag_review_enabled\": false\n}\n```\n\nIf your session ID is invalid, you'll get the `401` error.\n\n*Username/password authentication may be supported in the future.*\n\n#### Get\n\nThese methods allows you to get specific elements from Instagram while you know exactly what you're looking for.\n\n##### Errors handling\n\n`get` may return errors in the two following cases.\n\n- Request error : failed to get data from Instagram (HTTP code)\n- Parsing error : failed to parse data returned by Instagram (`406`)\n- No content : nothing to parse (`204`)\n- Authentication required : session ID required to access data (`401`)\n- Too many requests : rate limit exceeded (`429`)\n- Conflict : automation detected, password reset required (`409`)\n\n## Get profile by username\n\n```js\nInstaClient.getProfile(username)\n\t.then(profile =\u003e console.log(profile))\n\t.catch(err =\u003e console.error(err));\n```\n\nResult\n\n- `id` *string* - Instagram identifier, only used for stories\n- `name` *string* - public full [name](https://help.instagram.com/583107688369069)\n- `pic` *url* - public profile [picture](https://help.instagram.com/557544397610546)\n- `bio` *string* - public biography\n\u003cbr\u003e`website` *url* - public website\n\u003cbr\u003e[more info about bio \u0026 website](https://help.instagram.com/362497417173378)\n- `private` *boolean* - account [private state](https://help.instagram.com/448523408565555)\n- `access` *boolean* - access to the profile's feed\n\u003cbr\u003eIn order to have access to a private account's feed, you must have sent him a follow request that he accepted.\n- `verified` *boolean* - account [verified state](https://help.instagram.com/854227311295302)\n- `followers` *integer* - number of users following this profile\n- `following` *integer* - number of users this profile follows\n- `posts` *integer* - number of posts this profile published\n- `lastPosts` *array of posts* - last posts\n\u003cbr\u003eThis property is empty (`[]`) when the profile doesn't have any post but `null` if `access` is `false` (denied).\n- `link` *url* - link to the profile's page\n- `business` *string* - business category (when applicable and profile unblocked)\n- `user` *object* - user relevant properties **(while authenticated)** :\n\t- `mutualFollowers` *array of usernames* - people following you and this profile\n\t- `blocking` *boolean* - you blocked this profile\n\t- `blocked` *boolean* - this profile blocked you (only available property in `user` while `true`)\n\t- `requesting` *boolean* - you sent a follow request to this profile (if private)\n\t- `requested` *boolean* - this profile sent you a follow request (if yours is private)\n\t- `following` *boolean* - you're following this profile\n\t- `followed` *boolean* - this profile follows you\n\n## Get profile story (requires authentication)\n\n##### Using profile ID\n\n```js\nInstaClient.getProfileStoryById(id)\n    .then(profile =\u003e console.log(profile))\n    \t.catch(err =\u003e console.error(err));\n```\n\n### Using profile username (will automatically request profile ID)\n\n```js\nInstaClient.getProfileStory(username)\n    .then(profile =\u003e console.log(profile))\n    \t.catch(err =\u003e console.error(err));\n```\n\n##### Result\n\n- `unread` *boolean* - profile story is unread\n- `author` *object* - a subset of profile\n    - `username`\n    - `pic`\n- `user` *object* - user relevant properties\n    - `requesting`\n    - `following`\n- `items` *array of stories* - profile stories\n    - `url` *string* - link to original story file (`jpg`, `mp4`, ...)\n    - `type` *string* - story type : `photo` or `video`\n    - `timestamp` *epoch*\n    - `expirationTimestamp` *epoch*\n\n*Those methods will return `null` when a profile has no story.*\n\nNote : calling this method will not mark the story as read.\n\n## Get hashtag\n\n```js\nInstaClient.getHashtag(hashtag)\n\t.then(hashtag =\u003e console.log(hashtag))\n\t.catch(err =\u003e console.error(err));\n```\n\nResult\n\n- `pic` *url* - hashtag profile pic (can't find out how it is chosen)\n- `posts` *integer* - number of posts containing this hashtag\n- `featuredPosts` *array of posts* - featured posts published with this hashtag\n\u003cbr\u003e`lastPosts` *array of posts* - last posts published with this hashtag\n\u003cbr\u003e[more info about hashtag posts](https://help.instagram.com/777754038986618)\n- `link` *url* - link to the hashtag's page\n- `user` *object* - user relevant properties **(while authenticated)** :\n\t- `following` *boolean* - you [subscribed](https://help.instagram.com/2003408499915301) to this hashtag (receiving posts in your personal feed)\n\n### Get location by ID\n\nUnfortunately, using IDs is currently the only way to get a location, at least for now.\n\n```js\nInstaClient.getLocation(id)\n\t.then(location =\u003e console.log(location))\n\t.catch(err =\u003e console.error(err));\n```\n\nResult\n\n- `pic` *url* - location profile pic\n- `posts` *integer* - posts published from that location\n- `address` *object*\n\t- `street` *string*\n\t- `zipCode` *string*\n\t- `city` *string*\n\t- `latitude` *float*\n\t- `longitude` *float*\n- `website` *url* - place's website\n- `phone` *string* - place's contact phone number\n- `featuredPosts` *array of posts* - featured posts published from this location\n\u003cbr\u003e`lastPosts` *array of posts* - last posts published from this location\n- `link` *url* - link to this location's page\n\n### Array of posts\n\nThis is a subset of a real post, containing the following properties :\n\n- `shortcode` *string* - post identifier\n- `caption` *string* - post description\n- `comments` *integer* - number of comments\n- `likes` *integer* - number of likes\n- `thumbnail` *url* - post thumbnail\n\u003cbr\u003eAlways static image wether it's a photo or a video post, lower quality.\n\n## Get post by shortcode\n\nThe shortcode is the post's identifier : the link to a post is instagram.com/p/shortcode.\n\n```js\nInstaClient.getPost(shortcode)\n\t.then(post =\u003e console.log(post))\n\t.catch(err =\u003e console.error(err));\n```\n\nResult\n\n- `author` *object* - a subset of a profile's properties.\n\t- `username` *string*\n\t- `name` *string*\n\t- `pic` *url*\n\t- `verified` *boolean*\n\t- `link` *url*\n- `location`\n\t- `name` *string*\n\t- `city` *string*\n- `contents` *array of posts*\n\t- `type` *string* - post type : `photo` or `video`\n\t- `url` *string* - link to original post file (`jpg`, `mp4`, ...)\n\t- if `type` is `video` :\n\t\u003cbr\u003e`thumbnail` *string* - link to thumbnail\n\t\u003cbr\u003e`views` *integer* - number of views\n- `tagged` *array of usernames* - people tagged in post contents\n- `likes` *integer* - number of likes\n- `caption` *string* - post description\n- `hashtags` *array of hashtags* - hashtags mentioned in post description\n- `mentions` *array of usernames* - people mentioned in post description\n- `edited` *boolean* - caption edited\n- `comments` *array of objects* (Max 40)\n\t- `user` *string* - comment author's username\n\t- `content` *string* - comment content\n\t- `timestamp` *epoch*\n\t- `hashtags` *array of hashtags*\n\t- `mentions` *array of usernames*\n\t- `likes` *integer*\n- `commentCount` *integer*\n- `timestamp` *epoch*\n- `link` *string* - link to the post\n\n#### Paginated getters (require authentication)\n\nPaginated getters allows bulk data downloads.\n\nParams :\n- `maxCount` *integer* - max number of items to return\n- `pageId` *string* (optional) - page navigation identifier\n\nResult : array + `nextPageId` property\n\nSample :\n```js\n(async () =\u003e {\n\tconst page0 = await somePaginatedGetter(someId, 50);\n\tconst page1 = await somePaginatedGetter(someId, 50, page0.nextPageId);\n\tconst page2 = await somePaginatedGetter(someId, 50, page1.nextPageId);\n})();\n```\n\nThe `pageId`/`nextPageId` property may contain a string of digits, a base64 string, or a JSON string, but always must be leaved untouched.\n\n## Get profile posts\n\nResult in array : full post object\n\n##### Using profile ID\n\n```js\nInstaClient.getProfilePostsById(profileId, maxCount, pageId)\n    .then(posts =\u003e console.log(posts))\n    \t.catch(err =\u003e console.error(err));\n```\n\n##### Using profile username (will automatically request profile ID)\n\n```js\nInstaClient.getProfilePosts(profileUsername, maxCount, pageId)\n    .then(posts =\u003e console.log(posts))\n    \t.catch(err =\u003e console.error(err));\n```\n\n## Get post comments\n\n```js\nInstaClient.getPostComments(shortcode, maxCount, pageId)\n\t.then(posts =\u003e console.log(posts))\n\t.catch(err =\u003e console.error(err));\n```\n\nResult in array : comment object\n\n## Get hashtag posts\n\n```js\nInstaClient.getHashtagPosts(hashtag, maxCount, pageId)\n\t.then(posts =\u003e console.log(posts))\n\t.catch(err =\u003e console.error(err));\n```\n\nResult in array : partial post object\n\n## Get location posts\n\n```js\nInstaClient.getLocationPostsById(locationId, maxCount, pageId)\n\t.then(posts =\u003e console.log(posts))\n\t.catch(err =\u003e console.error(err));\n```\n\nResult in array : partial post object\n\n## Search\n\n## Search profile\n\n```js\nInstaClient.searchProfile(query)\n\t.then(profiles =\u003e console.log(profiles))\n\t.catch(err =\u003e console.error(err));\n```\n\nResult in array : a subset of profile.\n\n- `username`\n- `name`\n- `pic`\n- `private`\n- `verified`\n- `followers`\n- `user`\n\t- `following`\n\n## Search hashtag\n\n```js\nInstaClient.searchHashtag(hashtag)\n\t.then(hashtags =\u003e console.log(hashtags))\n\t.catch(err =\u003e console.error(err));\n```\n\nResult in array : a subset of hashtag.\n\n- `name`\n- `posts`\n\n## Search location\n\n```js\nInstaClient.searchLocation(location)\n\t.then(locations =\u003e console.log(locations))\n\t.catch(err =\u003e console.error(err));\n```\n\nResult in array : a subset of location.\n\n- `id`\n- `name`\n- `address`\n\t- `street`\n\t- `city`\n\t- `latitude`\n\t- `longitude`\n\n#### Subscribe to posts\n\n- `options` *object* (optional)\n    - `interval` *integer* (optional) - time in seconds between requests. **Default : 30**\n    - `lastPostShortcode` *string* (optional) - shortcode from which to begin if not the next one to be published.\n    - `fullPosts` *boolean* (optional) - fetch full post data, additional request required\n\n##### From user\n\n```js\nInstaClient.subscribeUserPosts(username, (post, err) =\u003e {\n    if(post)\n        console.log(post.shortcode);\n    else\n        console.error(err);\n}, {\n    interval,\n    lastPostShortcode,\n    fullPosts\n});\n```\n\n##### From hashtag\n\n```js\nInstaClient.subscribeHashtagPosts(hashtag, (post, err) =\u003e {\n    if(post)\n        console.log(post.shortcode);\n    else\n        console.error(err);\n}, {\n    interval,\n    lastPostShortcode,\n    fullPosts\n});\n```\n\n#### Account requests (user-relevant methods)\n\n## Get account notifications\n\n```js\nInstaClient.getAccountNotifications()\n\t.then(notifications =\u003e console.log(notifications))\n\t.catch(err =\u003e console.error(err));\n```\n\nResult in array : notification\n\n- `id` *string* - Notification identifier\n- `timestamp` *epoch*\n- `type` *string* - Notification type : `like`, `mention`, `comment`, `follow`\n- `post`\n\t- `shortcode`\n\t- `thumbnail`\n- `by`\n\t- `username`\n\t- `name`\n\t- `pic`\n- `content` *string* - Comment content (when applicable)\n\n##### Subscribe to account notifications\n\n- `options` *object* (optional)\n    - `interval` *integer* (optional) - time in seconds between requests. **Default : 30**\n    - `lastNotificationId` *string* (optional) - Notification ID\n\n```js\nInstaClient.subscribeAccountNotifications((post, err) =\u003e {\n    if(post)\n        console.log(post.shortcode);\n    else\n        console.error(err);\n}, {\n    interval,\n    lastNotificationId\n});\n```\n\n#### Get account stories\n\n```js\nInstaClient.getAccountStories()\n    .then(stories =\u003e console.log(stories))\n    .catch(err =\u003e console.error(err));\n```\n\nResult in array : inbox-like\n\n- `unread`\n- `author` *object* - a subset of a profile's properties.\n    - `id`\n    - `username`\n    - `pic`\n- `user` *object* - user relevant properties\n    - `requesting`\n    - `following`\n\n\n\n### Test\n\n- `git clone https://github.com/ezzcodeezzlife/ig-scraper.git`\n- `yarn install` or `npm install`\n- `yarn test` or `npm run test`\n\nOptional environment variables for more complete testing :\n- `SESSION_ID` : a session ID for authentication test and authenticated tests\n- `PUBLIC_PROFILE` : a public profile to access\n- `PRIVATE_PROFILE` : a private profile to access\n- `STORY_PROFILE_ID` : a profile ID with a story to read\n- `STORY_PROFILE_USERNAME` : a profile username with a story to read\n- `HASHTAG` (default value : `cat`) : a hashtag to fetch\n- `LOCATION_ID` (default value : `6889842` aka. Paris) : a location to fetch\n- `POST` : a post to fetch\n- `SEARCH_PROFILE` : a profile to search for\n- `SEARCH_HASHTAG` (default value : `cats`) : a hashtag to search for\n- `SEARCH_LOCATION` (default value : `Paris`) : a location to search for\n\nMethods not covered by tests :\n- `subscribeUserPosts`\n- `subscribeHashtagPosts`\n- `subscribeAccountNotifications`\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezzcodeezzlife%2Fscraper-instagram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fezzcodeezzlife%2Fscraper-instagram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezzcodeezzlife%2Fscraper-instagram/lists"}