instapro icon indicating copy to clipboard operation
instapro copied to clipboard

getUserByUsername only returns 12 edges

Open skylarweaver opened this issue 5 years ago • 3 comments

Great utility! Only issue I'm running into is that getUserByUsername only returns the most recent 12 posts. Is there anyway to increase the default number of posts returned or specify which amount we want returned?

It seems this might be b/c the ig website by default loads the first 12 results, then lazyloads the rest as you scroll. Any ideas how to fetch more posts at the beginning? Thanks!

skylarweaver avatar Apr 29 '19 18:04 skylarweaver

Yes, it is because the website loads 12 by default. This utility previously used Instagram's open Graph API endpoints but now those endpoints are either closed or require authentication. I will explore this further to see if I can get more posts. You are also welcome to create a PR if you'd like.

preethamvishy avatar Apr 30 '19 00:04 preethamvishy

Awesome, thanks man!

I checked out their network request a bit, and it looks like something might be possible by manipulating this client network request:

curl 'https://www.instagram.com/graphql/query/?query_hash=f2405b236d85e8296cf30347c9f08c2a&variables=%7B%22id%22%3A%2232265959%22%2C%22first%22%3A12%2C%22after%22%3A%22QVFBa3M5ZV8zZXpJZDZuZUh6V2VNQkRjeE9jRWkwZnlqMDhCUXBrd1RzMUZEcmJmMnBJYVRLd0NFVFpOdFlyUW9BLUJtckxXY0E4dnltUE1hNU8zNEM3OA%3D%3D%22%7D' -H 'Accept: */*' -H 'Referer: https://www.instagram.com/sky_earth_water/?hl=en' -H 'X-Requested-With: XMLHttpRequest' -H 'X-Instagram-GIS: 194c320739a14f30730902f0fcfc95b9' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36' -H 'X-IG-App-ID: 936619743392459' --compressed

The query parameters of that request decode to this: query_hash=f2405b236d85e8296cf30347c9f08c2a&variables={"id":"32265959","first":12,"after":"QVFBa3M5ZV8zZXpJZDZuZUh6V2VNQkRjeE9jRWkwZnlqMDhCUXBrd1RzMUZEcmJmMnBJYVRLd0NFVFpOdFlyUW9BLUJtckxXY0E4dnltUE1hNU8zNEM3OA=="}'

It seems "first":12 indicates that it should only pull the first 12 posts. Increasing that does seem to increase the number of posts is pull, but it seems it starts pulling posts starting from a random post. Maybe specified by the "after": ... variable, but idk what that after hash is referring to or how to get that...

Maybe you have some more insight?

skylarweaver avatar May 01 '19 15:05 skylarweaver

Hi @preethamvishy, have you had a chance to explore this any more? Any more insight into how to get more posts would be very helpful. Thank you!

skylarweaver avatar Jul 31 '19 19:07 skylarweaver