npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

igramapi

v1.48.3

Published

Instagram private API wrapper for full access to instagram

Downloads

11

Readme

Igramapi - Instagram API client

Next Major Version

Are you lost and looking for igramapi php/laravel? Now the name is Igramavel and it still uses the same instagram-user-feed lib.

This package/repository could be outdated, deleted, access made private, not working as it should, or something else. I can't guarantee its continuity, so if you experience problems please open a new issue or consider instagram-private-api. After Igramapi v1.48.0 the fork will no longer be synced with instagram-private-api and will be a standalone repository.

Table of Contents

Installation

From npm

npm install igramapi
yarn add igramapi

From github

npm install github:nsmle/igramapi

This package uses url-regex-safe (GitHub) to check for links when sending direct messages. By default, the safe regex engine re2 is not installed. ⚠ It's highly recommended for you to install re2 by running npm install re2, else you will be vulnerable to CVE-2020-7661.

Examples

Note for JavaScript users:_ As of Node v.13.5.0, there isn't support for ESModules and the 'import'-syntax. So you have to read the imports in the examples like this: import { IgApiClient } from 'igramapi'const { IgApiClient } = require('igramapi')

You can find more usage examples here.

import { IgApiClient } from 'igramapi';
import { sample } from 'lodash';

const ig = new IgApiClient();
// You must generate device id's before login.
// Id's generated based on seed
// So if you pass the same value as first argument - the same id's are generated every time
ig.state.generateDevice(process.env.IG_USERNAME);
// Optionally you can setup proxy url
ig.state.proxyUrl = process.env.IG_PROXY;
(async () => {
  // Execute all requests prior to authorization in the real Android application
  // Not required but recommended
  await ig.simulate.preLoginFlow();
  const loggedInUser = await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
  // The same as preLoginFlow()
  // Optionally wrap it to process.nextTick so we dont need to wait ending of this bunch of requests
  process.nextTick(async () => await ig.simulate.postLoginFlow());
  // Create UserFeed instance to get loggedInUser's posts
  const userFeed = ig.feed.user(loggedInUser.pk);
  const myPostsFirstPage = await userFeed.items();
  // All the feeds are auto-paginated, so you just need to call .items() sequentially to get next page
  const myPostsSecondPage = await userFeed.items();
  await ig.media.like({
    // Like our first post from first page or first post from second page randomly
    mediaId: sample([myPostsFirstPage[0].id, myPostsSecondPage[0].id]),
    moduleInfo: {
      module_name: 'profile',
      user_id: loggedInUser.pk,
      username: loggedInUser.username,
    },
    d: sample([0, 1]),
  });
})();

Basic concepts

You can find documentation in the docs folder. Consider starting in IgApiClient (index module), the root class.

You'll often see ig in the docs. This just refers to the client, an instance of IgApiClient holding the state for one user.

import { IgApiClient } from 'igramapi';

// This is the general convention on how to name the client
//    vv
const ig = new IgApiClient();

// login, load a session etc.

Repositories

Repositories implement low-level operations - every method sends exactly one api-request.

You access repositories on the client (IgApiClient) by their lower-case (camelCase) name without the Repository suffix. For example, you access the instance of AddressBookRepository by ig.addressBook.

Feeds

Feeds represent paginated endpoints like a user's feed (UserFeed). Think of feeds like (async-)iterators/streams/observables (in fact feeds are async iterable and observable (feed.item$)). Every feed is accessible via ig.feed.feedName() (camelCase name). ig.feed is the FeedFactory that creates feeds for you connected to the instance of ig.

Most of the feeds require initialization parameter(s), like a user-pk (id).

Services

Services will help you to maintain some actions without calling a couple repository methods or perform complex things like pre and postlogin flow simulations or photo/video publishing.

Debugging

In order to get debug infos provided by the library, you can enable debugging. The prefix for this library is ig. To get all debug logs (recommended) set the namespace to ig:*.

Node

In Node you only have to set the environment variable DEBUG to the desired namespace. Further information

Contribution

If you need features that is not implemented - feel free to implement and create PRs!

Plus we need some documentation, so if you are good in it - you are welcome.

Setting up your environment is described here.

Useful Links

|| Language | Description | |-|-|-| | instagram_mqtt | NodeJs | instagram realtime and fbns | | instagram-private-api | NodeJs | instagram private api client | | instagram-id-to-url-segment | NodeJs | convert the image url fragment to the media id | | instagram-user-feed | PHP | instagram browser api client | | igramavel | PHP | instagram restful api laravel | |||

Special thanks

  • Richard Hutta, original author of instagram-private-api library. Thanks to him for starting it.
  • Dmitry, co-author of instagram-private-api library.
  • Nerixyz, for writing a huge amount of code for instagram-private-api library.