Instagram-private-api: What's the recommended way to login?

Created on 21 Dec 2019  路  5Comments  路  Source: dilame/instagram-private-api

General Question

Read the Notes and fill out the form.
Switch to Preview for reading.

Notes

Your issue will be closed if you violate any rule below.

  • You need to include a meaningful descriptions and e.g. a screenshot.
  • You do not include screenshots of your code.
  • Read the Docs.
  • Capturing endpoints and similar can be found here
    (read it if you are going to ask about it).
  • You can delete this section after reading it.

Form

Put an [x] if you meet the condition, else leave [ ].

Question

A specific question, so it's understandable to anyone.
You may add pictures.

YOUR QUESTION HERE
Hi everyone, I'm new here.
I found this great module after some search and I tested it, I can't say anything accept "perfect! nice work!".
I know that my account can get banned while using this module in the wrong way, so I want to know what's the correct and the recommended way to login.
I checked some examples but everything is writen in typescript, and I only know js.
I know about saving session and similar things, and I should set limits for requests to avoid spam...
This is what I did for now:

require("dotenv");
const { IgApiClient } = require("instagram-private-api");
鈥媍onst ig = new IgApiClient();
ig.state.generateDevice(process.env.IG_USERNAME);
async function  IgLogin(){
  await ig.account.login(process.evn.IG_USERNAME, process.evn.IG_PASSWORD);
}

And thx.

question

Most helpful comment

what's the correct and the recommended way to login

The session example should contain the reccomended way.
You don't have to log in after loading the session so you can wrap it in an else {...}.
You can also call ig.simulate.pre/postLoginFlow() before and after logging in.

I checked some examples but everything is writen in typescript, and I only know js.

TypeScript is a superset of JavaScript. The examples there will often translate 1:1 to JavaScript (except the type annotations e.g. function(a: string): number "translates" to function(a) and node doesn't yet have ESModules so import {a} from 'b' would be const {a} = require('b'))

All 5 comments

what's the correct and the recommended way to login

The session example should contain the reccomended way.
You don't have to log in after loading the session so you can wrap it in an else {...}.
You can also call ig.simulate.pre/postLoginFlow() before and after logging in.

I checked some examples but everything is writen in typescript, and I only know js.

TypeScript is a superset of JavaScript. The examples there will often translate 1:1 to JavaScript (except the type annotations e.g. function(a: string): number "translates" to function(a) and node doesn't yet have ESModules so import {a} from 'b' would be const {a} = require('b'))

Thx.
What's the functionality of ig.simulate.preLoginFlow() and ig.simulate.postLoginFlow()?

preLoginFlow() makes the requests the app does before logging in and postLoginFlow() does it for the requests after logging in.

So these functions simulate some normal-default requetes in the app to make the API know that the account is a regular user and not a bot?

So these functions simulate some normal-default requetes in the app to make the API know that the account is a regular user and not a bot?

Right, although nothing is perfect.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

haliliceylan picture haliliceylan  路  29Comments

sagardalal21 picture sagardalal21  路  39Comments

LouenLeoncoeur picture LouenLeoncoeur  路  12Comments

MMrR0b0TT picture MMrR0b0TT  路  18Comments

prichey picture prichey  路  10Comments