Search code examples
node.jsproxyinstagram-api

How to use a proxy with the instagram-private-api for Node.js


Using a proxy with instagram-private-api.

Hi all, I spent a decent amount of time trying to figure this out and there is probably a really simple answer but I was seriously confused. When creating a session needed for the Instagram nodeJS API (private) you need a proxyUrl. I was wondering how to do / configure this? Do you need to create your own proxy server that you host?

Here is my code so far.

var Upload = require('instagram-private-api').V1;
var Client = require('instagram-private-api').V1;
var device = new Client.Device('test');
var storage = new Client.CookieFileStorage(__dirname + 
'/cookies/test.json');
var photo = require('instagram-private-api').V1;

var username = 'testusername'
var password = 'testpassword'
var proxyUrl = '???'


Client.Session.create(device, storage, username, password, proxyUrl)
var Upload = require('./node_modules/instagram-private-api/client/v1/Upload.js')
var session = new Client.Session(device, storage, 'test', 'test')

Upload.photo(session, 'aaaa.jpg')
        .then(function(upload) {
            console.log(upload.params.uploadId);

            return Media.configurePhoto(session, upload.params.uploadId, 'henlo world');

        })

        .then(function(medium) {
            console.log(medium.params)
        })

I know my code is probably seriously flawed as well, criticism is appreciated! Here's the link to the GitHub of the Node.JS wrapper mentioned. Here.


Solution

  • e Hi there Benjamin,

    I'm really looking forward to helping you.

    As already stated, this library won't be upkept and maintained and could become irrelevant in updates to the official API.

    I believe one has to set up a proxy url on their phone.