v15.0.1If I am not authenticated any url(no matter public user, or public post) except "/" results in IgLoginRequiredError.
If I am authenticated any igClient.request.send() request always results in a [TransformError].
A relevant issue is #774 Where @realinstadude has closed the issue with the comment "This is a network related error", I do understand that but how do I make it work? I also found some header that gives information whether a request is being sent from Europe(where I'm from) so I tried using a vpn provider to connect to a US server, but no luck, my ultimate goal is to be able to get single posts analyze them using cheerio to find the image source and download that, but I'm unsure as to how to properly send requests using this API's architecture!
import { IgApiClient } from "instagram-private-api";
const ig = new IgApiClient();
ig.state.generateDevice("username");
(async () => {
await ig.account.login("username", "password"); // Tried two different accounts, no success
ig.request
.send({ url: "/" }) // url can be a user(try '/instagram'), a post(try '/p/CHDzGgCs568') It doesn't matter
.then((value) => {
console.log("SUCCESS, ", value);
})
.catch((err) => {
console.error(err.name);
console.error(err.message);
console.error(err.stack);
console.error(err.cause);
});
})();
[object Object]
TransformError: [object Object]
at Request.faultTolerantRequest (some_dirs/ig_api_test/node_modules/instagram-private-api/dist/core/request.js:132:19)
at async Request.send (some_dirs/ig_api_test/node_modules/instagram-private-api/dist/core/request.js:47:26)
{
name:'SyntaxError',
message:"Unexpected '<'",
at:2,
text: '\n' +
'<!DOCTYPE html>\n' +
'<html lang="en" class="no-js logged-in client-root touch">\n' +
' <head>\n' +
' <meta charset="utf-8">\n' +
' <meta http-equiv="X-UA-Compatible" content="IE=edge">\n' +
'\n' +
' <title>\n' +
'Instagram on Instagram: “To honor Día de Muertos, Mexico City-based artist and creative director Mauricio Groenewold (@groenewold_m) dreams up lively illustrations…”\n' +
'</title>\n' +
'\n' +
' \n' +
' <meta name="robots" content="noimageindex, noarchive">\n' +
' <meta name="apple-mobile-web-app-status-bar-style" content="default">\n' +
' <meta name="mobile-web-app-capable" content="yes">\n' +
' <meta name="theme-color" content="#ffffff">\n' +
' <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover">\n' +
' <link rel="manifest" href="/data/manifest.json">\n' +
'\n' +
' <link rel="preload" href="/static/bundles/metro/ConsumerUICommons.css/7839ae0709ff.css" as="style" type="text/css" crossorigin="anonymous" />\n' +
'<link rel="preload" href="/static/bundles/metro/Consumer.css/e5b9b800d311.css" as="style" type="text/css" crossorigin="anonymous" />\n' +
'<link rel="preload" href="/static/bundles/metro/PostPageContainer.css/13422d7df265.css" as="style" type="text/css" crossorigin="anonymous" />\n' +
'<link rel="preload" href="/static/bundles/metro/Vendor.js/5a56d51ae30f.js" as="script" type="text/javascript" crossorigin="anonymous" />\n' +
'<link rel="preload" href="/static/bundles/metro/en_US.js/6b7baefeb59f.js" as="script" type="text/javascript" crossorigin="anonymous" />\n' +
'<link rel="preload" href="/static/bundles/metro/ConsumerLibCommons.js/fb1048dd0d43.js" as="script" type="text/javascript" crossorigin="anonymous" />\n' +
'<link rel="preload" href="/static/bundles/metro/ConsumerUICommons.js/2efd69640133.js" as="script" type="text/javascript" crossorigin="anonymous" />\n' +
'<link rel="preload" href="/static/bundles/metro/ConsumerAsyncCommons.js/c4ca4238a0b9.js" as="script" type="text/javascript" crossorigin="anonymous" />\n' +
'<link rel="preload" href="/static/bundles/metro/Consumer.js/c5ba0f097e85.js" as="script" type="text/javascript" crossorigin="anonymous" />\n' +
'<link rel="preload" href="/static/bundles/metro/PostPageContainer.js/a90a8ebefd65.js" as="script" type="text/javascript" crossorigin="anonymous" />\n' +
' \n' +
' \n' +
'\n' +
' <script type="text/javascript">\n' +
' (function() {\n' +
' var docElement = document.documentElement;\n' +
" var classRE = new RegExp('(^|\\\\s)no-js(\\\\s|$)');\n" +
' var className = docElement.className;\n' +
" docElement.className = className.replace(classRE, '$1js$2');\n" +
'})();\n' +
'</script>\n' +
' <script type="text/javascript">\n' +
'(function() {\n' +
" if ('PerformanceObserver' in window && 'PerformancePaintTiming' in window) {\n" +
' window.__bufferedPerformance = [];\n' +
' var ob = new PerformanceObserver(function(e) {\n' +
' window.__bufferedPerformance.push.apply(window.__bufferedPerformance,e.getEntries());\n' +
' });\n' +
" ob.observe({entryTypes:['paint']});\n" +
' }\n' +
'\n' +
' window.__bufferedErrors = [];\n' +
' window.onerror = function(message, url, line, column, error) {\n' +
' window.__bufferedErrors.push({\n' +
' message: message,\n' +
' url: url,\n' +
' line: line,\n' +
' column: column,\n' +
' error: error\n' +
' });\n' +
' return false;\n' +
' };\n' +
' window.__initialData = {\n' +
' pending: true,\n' +
' waiting: []\n' +
' };\n' +
' function asyncFetchSharedData(extra) {\n' +
' var sharedDataReq = new XMLHttpRequest();\n' +
' sharedDataReq.onreadystatechange = function() {\n' +
' if (sharedDataReq.readyState === 4) {\n' +
' if(sharedDataReq.status === 200){\n' +
' var sharedData = JSON.parse(sharedDataReq.responseText);\n' +
' window.__initialDataLoaded(sharedData, extra);\n' +
' }\n' +
' }\n' +
' }\n' +
" sharedDataReq.open('GET', '/data/shared_data/', true);\n" +
' sharedDataReq.send(null);\n' +
' }\n' +
' function notifyLoaded(item, data) {\n' +
' item.pending = false;\n' +
' item.data = data;\n' +
' for (var i = 0;i < item.waiting.length; ++i) {\n' +
' item.waiting[i].resolve(item.data);\n' +
' }\n' +
' item.waiting = [];\n' +
' }\n' +
' function notifyError(item, msg) {\n' +
' item.pending = false;\n' +
' item.error = new Error(msg);\n' +
' for (var i = 0;i < item.waiting.length; ++i) {\n' +
' item.waiting[i].reject(item.error);\n' +
' }\n' +
' item.waiting = [];\n' +
' }\n' +
' window.__initialDataLoaded = function(initialData, extraData) {\n' +
' if (extraData) {\n' +
' for (var key in extraData) {\n' +
' initialData[key] = extraData[key];\n' +
' }\n' +
' }\n' +
' notifyLoaded(window.__initialData, initialData);\n' +
' };\n' +
' window.__initialDataError = function(msg) {\n' +
' notifyError(window.__initialData, msg);\n' +
' };\n' +
' window.__additionalData = {};\n' +
' window.__pendingAdditionalData = function(paths) {\n' +
' for (var i = 0;i < paths.length; ++i) {\n' +
' window.__additionalData[paths[i]] = {\n' +
' pending: true,\n' +
' waiting: []\n' +
' };\n' +
' }\n' +
' };\n' +
' window.__additionalDataLoaded = function(path, data) {\n' +
' if (path in window.__additionalData) {\n' +
' notifyLoaded(window.__additionalData[path], data);\n' +
' } else {\n' +
` console.error('Unexpected additional data loaded "' + path + '"');\n` +
' }\n' +
' };\n' +
' window.__additionalDataError = function(path, msg) {\n' +
' if (path in window.__additionalData) {\n' +
' notifyError(window.__additionalData[path], msg);\n' +
' } else {\n' +
` console.error('Unexpected additional data encountered an error "' + path + '": ' + msg);\n` +
' }\n' +
' };\n' +
' \n' +
'})();\n' +
'</script><script type="text/javascript">\n' +
'\n' +
'/*\n' +
' Copyright 2018 Google Inc. All Rights Reserved.\n' +
' Licensed under the Apache License, Version 2.0 (the "License");\n' +
' you may not use this file except in compliance with the License.\n' +
' You may obtain a copy of the License at\n' +
'\n' +
' http://www.apache.org/licenses/LICENSE-2.0\n' +
'\n' +
' Unless required by applicable law or agreed to in writing, software\n' +
' distributed under the License is distributed on an "AS IS" BASIS,\n' +
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n' +
' See the License for the specific language governing permissions and\n' +
' limitations under the License.\n' +
'*/\n' +
'\n' +
'(function(){function g(a,c){b||(b=a,f=c,h.forEach(function(a){removeEventListener(a,l,e)}),m())}function m(){b&&f&&0<d.length&&(d.forEach(function(a){a(b,f)}),d=[])}function n(a,c){function k(){g(a,c);d()}function b(){d()}function d(){removeEventListener("pointerup",k,e);removeEventListener("pointercancel",b,e)}addEventListener("pointerup",k,e);addEventListener("pointercancel",b,e)}function l(a){if(a.cancelable){var c=performance.now(),b=a.timeStamp;b>c&&(c=+new Date);c-=b;"pointerdown"==a.type?n(c,\n' +
'a):g(c,a)}}var e={passive:!0,capture:!0},h=["click","mousedown","keydown","touchstart","pointerdown"],b,f,d=[];h.forEach(function(a){addEventListener(a,l,e)});window.perfMetrics=window.perfMetrics||{};window.perfMetrics.onFirstInputDelay=function(a){d.push(a);m()}})();\n' +
'</script>\n' +
' \n' +
' <link rel="apple-touch-icon-precomposed" sizes="76x76" href="/static/images/ico/apple-touch-icon-76x76-precomposed.png/666282be8229.png">\n' +
' <link rel="apple-touch-icon-precomposed" sizes="120x120" href="/static/images/ico/apple-touch-icon-120x120-precomposed.png/8a5bd3f267b1.png">\n' +
' <link rel="apple-touch-icon-precomposed" sizes="152x152" href="/static/images/ico/apple-touch-icon-152x152-precomposed.png/68193576ffc5.png">\n' +
' <link rel="apple-touch-icon-precomposed" sizes="167x167" href="/static/images/ico/apple-touch-icon-167x167-precomposed.png/4985e31c9100.png">\n' +
' <link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/images/ico/apple-touch-icon-180x180-precomposed.png/c06fdb2357bd.png">\n' +
' \n' +
' <link rel="icon" sizes="192x192" href="/static/images/ico/favicon-192.png/68d99ba29cc8.png">\n' +
' \n' +
' \n' +
' \n' +
' <link rel="mask-icon" href="/static/images/ico/favicon.svg/fc72dd4bfde8.svg" color="#262626">\n' +
' \n' +
' <link rel="shortcut icon" type="image/x-icon" href="/static/images/ico/favicon.ico/36b3ee2d91ed.ico">\n' +
' \n' +
' \n' +
' \n' +
' \n' +
' \n' +
' <meta property="al:ios:app_name" content="Instagram" />\n' +
' <meta property="al:ios:app_store_id" content="389801252" />\n' +
' <meta property="al:ios:url" content="instagram://media?id=2433012970804190908" />\n' +
' <meta property="al:android:app_name" content="Instagram" />\n' +
' <meta property="al:android:package" content="com.instagram.android" />\n' +
' <meta property="al:android:url" content="https://www.instagram.com/p/CHDzGgCs568/" />\n' +
' \n' +
' <link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/" hreflang="x-default" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=en" hreflang="en" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=fr" hreflang="fr" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=it" hreflang="it" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=de" hreflang="de" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=es" hreflang="es" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=zh-cn" hreflang="zh-cn" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=zh-tw" hreflang="zh-tw" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=ja" hreflang="ja" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=ko" hreflang="ko" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=pt" hreflang="pt" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=pt-br" hreflang="pt-br" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=af" hreflang="af" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=cs" hreflang="cs" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=da" hreflang="da" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CHDzGgCs568/?hl=el" hreflang="el" />\n' +
'<link rel="alternate" href="https://www.instagram.com/p/CH'... 84961 more characters
}
You're making a request to i.instagram.comand it redirtects you to www.instagram.com. This is to be expected. There are examples on how to do requests with this library. If you really need these custom requests, then consider making a PR to add them to a repository/service/feed/entity.
You're making a request to
i.instagram.comand it redirtects you towww.instagram.com. This is to be expected. There are examples on how to do requests with this library. If you really need these custom requests, then consider making a PR to add them to a repository/service/feed/entity.
So i.instagram.com is the private API or the mobile version?
is the private API or the mobile version?
i.instagram.com is the base of the mobile version. And the private api emulates a mobile client.
is the private API or the mobile version?
i.instagram.comis the base of the mobile version. And the private api emulates a mobile client.
So currently there is no way to make an authenticated custom instagram request with your libraries default headers and other config?
So currently there is no way to make an authenticated custom instagram request with your libraries
You can take a look at the requests in the repositories, they're all using this method.
So currently there is no way to make an authenticated custom instagram request with your libraries
You can take a look at the requests in the repositories, they're all using this method.
Thank you so much, I solved my problem through some digging in the architecture, I would highly suggest redoing the documentation and putting more information for beginners like me both with node and instagram-private-api, so they have an easier transition :+1: :)