Auth Module

The auth module is a low-level interface to the SplatNet 3 API. It provides three main classes and a helper class.

The NSO class contains the logic for authenticating with Nintendo’s servers and obtaining the right access tokens. It generates the necessary headers, bodies, and cookies for the requests to the SplatNet 3 API. It provides methods to generate the gtoken and the bullet_token. It also provides the option to change the method that is used to generate the ftoken. This is useful if you wish to use a different method to generate the ftoken than querying a third-party website running an emulated version of the Nintendo Switch Online app.

The TokenManager class provides an interface to store, retrieve, and generate the tokens that are required to make requests to the SplatNet 3 API. The Token class is a helper class that is used by the TokenManager class to store the tokens alongside their token_type.

The GraphQLQueries class contains the GraphQL queries that are used to query the SplatNet 3 API. It provides methods to generate the GraphQL query, as well as a method to obtain the query_hash that is required to make the request through a hashmap of the query names to their query_hash.

For more information on the login process, see the Nintendo Switch Online Login Flow page.

Submodules

class splatnet3_scraper.auth.NSO

The NSO class contains all the logic to proceed through the login flow. This class also holds various properties that are used to make requests to the Nintendo Switch Online API. Login flow is roughly as follows, assuming the user has never generated a session token before:

Parameters:
session : Session

class splatnet3_scraper.auth.TokenManager

Manages the tokens used for authentication. Handles regeneration and interaction with the keychain. This class is meant to mostly be used via its “get” method

Parameters:
nso : NSO | None

f_token_url : str | list[str]

env_manager : EnvironmentVariablesManager | None

origin : Literal['memory', 'env', 'file']

origin_data : str | None

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.

class splatnet3_scraper.auth.EnvironmentVariablesManager

Manages environment variables for the scraper.

class splatnet3_scraper.auth.Token

Class that represents a token. This class is meant to store the token itself, the type of token it is, and the time it was created. It can be used to check if the token is expired or display the time left before it expires. It also provides convenience methods for getting all sorts of metadata about the token.

Parameters:
value : str

name : str

timestamp : float