dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
6.02k stars 1.14k forks source link

Raw data requests for medias #978

Closed DrRek closed 4 years ago

DrRek commented 5 years ago

Hi, I think it could be useful to some functions in order to replicate the api calls made by the app to retrieve the actual raw data (img or video) of some medias.

This could help bot creators to fully simulate the calls flow made by the real application and avoid to be detected as bot.

Use case: after retrieving media from the timeline feed we should be able to send a request to retrieve profile pics, photos and videos. Of course in the real application lots of information would be cached but this logic should be implemented by the dev using this library and not the library itself.

Nerixyz commented 5 years ago

There's nothing fancy going on. You can set the user-agent to the one provided by ig.state.appUserAgent and the headers X-FB-HTTP-Engine: Liger and Estimated-Size-Bytes: {estimatedBytes} but that's it.

after retrieving media from the timeline feed we should be able to send a request to retrieve profile pics, photos and videos.

That's already supported.

import * as requestPromise from 'request-promise';
const download = (url) => requestPromise.get({ 
      url, 
      encoding: null,
      // not needed even without these it works
      headers: {
            'Accept-Encoding': 'gzip',
            'Connection': 'close',
            'X-FB-HTTP-Engine': 'Liger',
            'User-Agent': ig.state.appUserAgent,
      },
});