class splatnet3_scraper.auth.GraphQLQueries

The GraphQLQueries class that contains the GraphQL queries used by splatnet3_scraper. The Nintendo Switch Online API only allows persistent queries, so making queries requires using the hashes for said queries. The great folks over at imink have a GitHub Actions workflow that checks for and updates the hashes for the queries every five minutes. The hashes are stored in a JSON file that is hosted on GitHub. This class automatically downloads the JSON file and stores the hashes in a dictionary. The hashes are then used to make queries to the Nintendo Switch Online API and can be accessed using their string names.

Constructors

GraphQLQueries()

Initializes the GraphQLQueries class. Initializes a requests.Session and stores it in the session attribute. Also gets the hashes for the GraphQL queries and stores them in the hash_map attribute. The hashes are stored in a dictionary where the keys are the names of the queries and the values are the hashes.

Methods

get_query(query_name)

Gets a GraphQL query hash given the name of the query.

query(query_name, bullet_token, gtoken, language, ...)

Makes a GraphQL query. This method is a wrapper around the query_hash method. It gets the query hash using the get_query method and then calls the query_hash method to make the request. For more information on the valid queries, see the queries page of the documentation.

query_body(query_name, variables={})

Generates the body for the GraphQL queries, as a string.

query_body_hash(query_hash, variables={})

Generates the body for the GraphQL queries, as a string.

query_hash(query_hash, bullet_token, gtoken, language, ...)

Makes a GraphQL query using the persisted query hash. This method generates the headers and body for the query and then makes the request. For more information on the valid queries, see the queries page of the documentation.

query_header(bullet_token, language, user_agent=None, override={})

Generates the headers that are used for the GraphQL queries made for the SplatNet 3 API.