Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get query_hash? #7

Open
Kingson opened this issue May 3, 2018 · 22 comments
Open

How to get query_hash? #7

Kingson opened this issue May 3, 2018 · 22 comments

Comments

@Kingson
Copy link

Kingson commented May 3, 2018

I would like to get query hash, any helpful info for me, thanks.

@alexhoma
Copy link
Contributor

alexhoma commented May 3, 2018

Hi! Here you have the specification: /docs/setup.md#how-to-get-your-query-hash-old-query-id

Into the docs/ directory you will see some examples and specifications of the library.

@Kingson
Copy link
Author

Kingson commented May 3, 2018

@alexhoma Thanks for your replay, I read the docs, but I want to generate query hash by myself.
Instagram how to generate "42323d64886122307be10013ad2dcc44"?

@Kingson
Copy link
Author

Kingson commented May 3, 2018

@alexhoma query_hash does not change forever?

@idkm23
Copy link

idkm23 commented Mar 1, 2019

what is the point of query_hash? I would expect it would be a way from instagram to confirm the query is coming from an informed sender. But if the hash is consistent, (i.e. doesn't have a parameter like time of day) then what is the point?

@hexadeciman
Copy link

hexadeciman commented Apr 26, 2019

I would expect it would be a way from instagram to confirm the query is coming from an informed sender.

It is not, it's just a way for them to cache the query params so that they can store and return the response faster.
Read more here: https://stackoverflow.com/questions/54238696/what-is-query-hash-in-instagram

You should be able to generate it, using i.e. hash.js package

@jonbesga
Copy link

jonbesga commented Jul 13, 2019

Hi @hexadeciman. I don't think the answer in the Stack Overflow thread is correct as the query_hash is always the same for every request (f2405b236d85e8296cf30347c9f08c2a) but the query params are differents everytime. If they were caching the query params with this method the query_hash should be different for each request.

@hexadeciman
Copy link

hexadeciman commented Jul 15, 2019

I just checked and it is different for every query
image
It just seems to stay the same for pagination.

@jonbesga
Copy link

jonbesga commented Jul 15, 2019

Hmm, weird.

For example, I'm loading @mileycyrus and @instagram.

First request for both accounts has the following query hashes (the same):

Miley: aec5501414615eca36a9acf075655b1e
Instagram: aec5501414615eca36a9acf075655b1e

In successive requests, for pagination, again the same:

Miley: query_hash: f2405b236d85e8296cf30347c9f08c2a
Instagram: query_hash: f2405b236d85e8296cf30347c9f08c2a

Also, they send all the data instead of first the query_hash. So this defeats the concept of the automated persisted queries

Edit: All of this is anonymously. I'm not logged in.

@oleksiivykhor
Copy link

oleksiivykhor commented Aug 9, 2019

Hello, @Kingson, query hash you can find in browser dev tools (https://github.com/mineur/instagram-parser/blob/master/docs/setup.md#how-to-get-your-query-hash-old-query-id) and then in neighbor tab JS you can find it in one of many loaded JS files, by Ctrl + F. Then before each request you can get content of this JS file from the link in html and parse generated query hash by regex.

@webszy
Copy link

webszy commented Aug 13, 2019

Need help for stories?how can i get stories now?

@benocd
Copy link

benocd commented Dec 30, 2019

Does the query hash ever expire? or does it have a query limit?

@KaKi87
Copy link

KaKi87 commented Jun 18, 2020

Hello,
So there is no way to automatically get the query hash ?

@meshchaninov
Copy link

query_hash hardcoded in one of *.js files on instagram. If u want to get hash, u should parse js files.

@KaKi87
Copy link

KaKi87 commented Jul 7, 2020

Yes, I actually found out. Thanks !

@anuuzsoni

This comment was marked as spam.

@KaKi87
Copy link

KaKi87 commented Mar 15, 2021

Have a look at this.

@anuuzsoni

This comment was marked as spam.

@anuuzsoni

This comment was marked as spam.

@hoosnick
Copy link

hoosnick commented Mar 17, 2022

@meshchaninov thanks, really it is in the static JS files.
Exactly the path: /static/bundles/metro/ConsumerLibCommons.js/gEnEraTeD_sTr.js

instagram

@Changlon
Copy link

@meshchaninov谢谢,真的是在静态 JS 文件中。 具体路径:/static/bundles/metro/ConsumerLibCommons.js/gEnEraTeD_sTr.js

Instagram

i do not kown why my queryId as same as yourself ! but the name of the .js filepath was different, and i can not access your .js filepath url

@thethiny
Copy link

thethiny commented Oct 16, 2022

hash_query does not hash the variables or the parameters, it hashes the path.
Lets say your actual path is /graphql and your payload is

{
    "user": {
        "profile": [
            "username",
            "user_id",
            "profile_picture"
        ],
        "feed": {
            "posts": {
                "data": [
                    "image_url"
                ],
                "page_size": "{{variables.max_count}}"
            }
        }
    }
}

Then this graphql payload will be hashed and it becomes d4d88dc1500312af6f937f7b804c68c3. Now instead of doing that on /graphql you do /graphql/query/?query_hash=d4d88dc1500312af6f937f7b804c68c3. This way you hashed the payload, as in you hashed the "keys" that are required from the graphql. So when you pass variables as a param then the payload does not actually change, because the variables are constant as well, and you are changing them on the backend, and not in the payload.

@Skuxblan
Copy link

Any thoughts how to get query hash now days? Seems it changed and we can't get it in same way anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests