1.0.1 • Published 6 years ago

instagram-private-api-auth v1.0.1

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

instagram-private-api-auth

npm.io npm.io


Wrapper for instagram-private-api that support Two Factor Authentication (2FA) and have simple console interface.


Installation

npm install instagram-private-api
npm install instagram-private-api-auth

or

npm install git+https://git@github.com/dilame/instagram-private-api.git
npm install git+https://git@github.com/ini0n/instagram-private-api-auth.git

Example

Get session by credentials and get last user media in profile.

const Client = require('instagram-private-api').V1
const AuthService = require('instagram-private-api-auth').AuthService(Client)
const _ = require('lodash')

async function getLastUserMedia(session, userId) {
    const feed = new Client.Feed.UserMedia(session, userId)
    const lastMedias = await feed.get()
    return _.head(lastMedias)
}

async function main() {
    try {
        // AuthService.getSession(username:string, password:string, proxyUrl?:string)
        const userSession = await AuthService.getSession('username', 'password')
        const account = await userSession.getAccount()
        let lastUserMedia = await getLastUserMedia(userSession, account.params.id)
        // lastUserMedia should be Media {}
        console.log(lastUserMedia)
    } catch (error) { 
        console.log(error)
    }
}

main().finally(() => process.exit(1))