{"id":16596048,"url":"https://github.com/edixonalberto/instagrapi","last_synced_at":"2025-10-29T12:30:47.186Z","repository":{"id":57274832,"uuid":"315739344","full_name":"EdixonAlberto/instagrapi","owner":"EdixonAlberto","description":"Library to obtain information from an Instagram account in a friendly and intuitive way","archived":false,"fork":false,"pushed_at":"2023-05-17T04:16:01.000Z","size":607,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-02T01:23:28.773Z","etag":null,"topics":["api","instragram","node","portfolio","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/instagrapi","language":"TypeScript","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/EdixonAlberto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":"edixonp","open_collective":null,"ko_fi":"edixon","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.paypal.com/paypalme/edixonp"]}},"created_at":"2020-11-24T20:00:24.000Z","updated_at":"2024-01-12T14:38:23.000Z","dependencies_parsed_at":"2022-09-18T09:12:23.098Z","dependency_job_id":null,"html_url":"https://github.com/EdixonAlberto/instagrapi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"EdixonAlberto/template-node-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdixonAlberto%2Finstagrapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdixonAlberto%2Finstagrapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdixonAlberto%2Finstagrapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdixonAlberto%2Finstagrapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EdixonAlberto","download_url":"https://codeload.github.com/EdixonAlberto/instagrapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238817720,"owners_count":19535580,"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","instragram","node","portfolio","typescript"],"created_at":"2024-10-11T23:52:15.432Z","updated_at":"2025-10-29T12:30:46.797Z","avatar_url":"https://github.com/EdixonAlberto.png","language":"TypeScript","funding_links":["https://patreon.com/edixonp","https://ko-fi.com/edixon","https://www.paypal.com/paypalme/edixonp"],"categories":[],"sub_categories":[],"readme":"# Instagrapi\n\n[![](https://img.shields.io/badge/author-Edixon_Piña-yellow?style=for-the-badge)](https://github.com/EdixonAlberto/)\n[![](https://img.shields.io/github/license/edixonalberto/instagrapi?style=for-the-badge)](LICENSE)\n[![](https://img.shields.io/npm/v/instagrapi?color=CB0000\u0026style=for-the-badge)](https://npmjs.com/package/instagrapi)\n[![](https://img.shields.io/npm/dt/instagrapi?color=CB0000\u0026style=for-the-badge)](https://npmjs.com/package/instagrapi)\n\n[![](https://img.shields.io/badge/types-TypeScript-blue?style=for-the-badge)](https://github.com/microsoft/TypeScript)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge)](https://github.com/prettier/prettier)\n\nLibrary to obtain information from an Instagram account in a friendly and intuitive way.\n\nThe library works as a wrapper for the basic Instagram API, to abstract long or confusing property names and have a\nclean and readable data structure.\n\nCreated with NodeJS and Typescript, all types are exposed for use.\n\u003cimg src=\"https://github.com/EdixonAlberto/instagrapi/blob/main/images/typescript.png\" width=\"18px\" alt=\"Logo typescript\" /\u003e +\n💗\n\n\u003e 📃 **NOTE:** This library can only be used on the server with Nodejs.\n\n\u003e 📃 **NOTE:** Login to Instagram required to obtain an ID.\n\n\u003e 📃 **NOTE:** In version 4.x.x the \"getPost\" method no longer works due to changes in the Instagram api.\n\n### 🌐 [Demo Web Site](https://edixonalberto.github.io/instagrapi) \u0026#x279c;\n\n### 🔌 [Example in Nodejs](https://github.com/EdixonAlberto/service-instagrapi) \u0026#x279c;\n\n## Installation\n\n```sh\nnpm install instagrapi\n# or\nyarn add instagrapi\n```\n\n## Usage\n\nFirst you must get the cookie called \"sessionId\" by logging in to your instagram account. To do this you must follow\nthese steps:\n\n1. Go to https://www.instagram.com\n2. If you don't have a session logged in start one\n3. Open development tools witch `Ctrl + Shift + I`\n4. Get to the `application` section and then to `Cookies` and select on the right hand side `sessionId`\n\nNow you can use the library by instantiating an object and passing the `sessionId` as an argument\n\n```js\nconst { Instagrapi } = require('instagrapi')\n\nconst instagrapi = new Instagrapi({\n  sessionId: process.env.SESSION_ID // Load sessionId from an environment variable\n})\n\ninstagrapi.getProfile('USERNAME').then(profile =\u003e {\n  console.log(profile.followers) // Numbers followers of instagram account\n})\n```\n\nUsing typescript and async/await.\n\n```ts\nimport { Instagrapi, TPost, TComment } from 'instagrapi'\n\nconst instagrapi = new Instagrapi({\n  sessionId: process.env.SESSION_ID\n})\n\nasync function getComments(): Promise\u003cstring[] | undefined\u003e {\n  try {\n    const post: TPost = await instagrapi.getPost('POST_URL')\n    const comments: string[] = post.previewComments.map((comment: TComment) =\u003e comment.content)\n\n    console.log(comments) // Preview comments of the post\n\n    return comments\n  } catch (error) {\n    console.error(error)\n  }\n}\n\ngetComments()\n```\n\n## Media Files\n\nBy default Instagram API return media files via a CDN configured with CORS rules so tha they can only be consumed from\nthe official page.\n\nTo work around this you can build your own proxy server and add it in instance confiuration. In this way the library\nwill automatically add the proxy as a prefix in all the media files that are found in the response.\n\n```js\nconst instagrapi = new Instagrapi({\n  sessionId: process.env.SESSION_ID,\n  proxy: 'https://proxy-example.com'\n})\n\ninstagrapi.getProfile('USERNAME').then(profile =\u003e {\n  const imgUrl = profile.image.standard\n\n  console.log(imgUrl) /* https://proxy-example.com/img-url... */\n})\n```\n\n## Methods\n\n- `getProfile(USERNAME)`\n\nGet all the profile information of an instagram account. Receives as argument: `USERNAME`, the username of the instagram\naccount.\n\nType of output in typescript:\n\n```ts\ntype TProfile = {\n  username: string\n  name: string\n  image: {\n    standard: string\n    hd: string\n  }\n  qtyPosts: number\n  followers: number\n  following: number\n  biography: string\n  externalUrl: string\n  isBusiness: boolean\n  isVerified: boolean\n  isPrivate: boolean\n}\n```\n\n- `getLastPosts(USERNAME)`\n\nGet the last 12 posts of an instagram account. Receives as argument: `USERNAME`, the username of the instagram account.\n\nType of output in typescript:\n\n```ts\ntype TLastPosts = Array\u003c{\n  postUrl: string\n  image: string\n  video: null | {\n    url: string\n    views: number | null\n  }\n  content: string | null\n  likes: number\n  qtyComments: number\n}\u003e\n```\n\n- `getPost(POST_URL):`\n\nGet all the details of a post of an instagram account. Receives as argument `POST_URL`, the url of the post on\ninstagram.\n\nType of output in typescript:\n\n```ts\ntype TPost = {\n  postUrl: string\n  image: {\n    standard: string\n    hd: string\n  }\n  video: TVideo | null\n  content: string | null\n  likes: number\n  qtyComments: number\n  gallery: Array\u003cTMedia\u003e\n  author: TAuthor\n  coauthors: Array\u003cTAuthor\u003e\n  previewComments: Array\u003cTComment\u003e\n  location: null | {\n    country: string | null\n    region: string | null\n    city: string | null\n    street: string | null\n    coordinates: {\n      lat: number\n      lng: number\n    }\n  }\n  date: string\n}\n```\n\n## License\n\n[MIT](LICENSE) \u0026copy; Edixon Piña\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedixonalberto%2Finstagrapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedixonalberto%2Finstagrapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedixonalberto%2Finstagrapi/lists"}