Query Module¶
The query module is a high-level interface to the SplatNet 3 API. It provides a simple interface for making queries to the API, and automatically handles authentication, session management, and token refreshing.
The main class in this module is QueryHandler, which is used to make
queries to the API. It is designed to be as easy to use as possible, and its
primary public method is QueryHandler.query(), which takes a query string
and, if necessary, a dictionary containing query variables to pass to the API.
It returns a QueryResponse object, which contains the response data
from the API as well as some metadata about the query. See the documentation
for QueryHandler and QueryResponse for more details.
Additionally, the JSONParser class is provided for more advanced use
cases. It is not necessary to use this class directly, but it is provided for
those who wish to do so. As of version 0.5.0, this class is not being used
internally by any other class, and may be removed in a future version.
This module currently has no plans to support a CLI interface, and it is intended to be used as a library for other projects.
Submodules¶
- class splatnet3_scraper.query.QueryHandler
The QueryHandler class is the main class of the
splatnet3_scraper.querymodule. It abstracts away the underlying implementation details of making queries to the SplatNet 3 API and makes it extremely easy to use. Token management is also handled by the QueryHandler so the user does not have to worry about having to regenerate tokens when they expire. The only exception to this is the session token, which the user must handle themselves as it is not possible to regenerate it automatically. The QueryHandler class is initialized with a Config class, which contains all the configuration options that the user can set. The QueryHandler class also contains multiple factory methods to create a new instance of the class to make it setting up the Config class much easier. The primary mode of operating the class is through thequerymethod, which takes a query name and a dictionary of arguments and returns a QueryResponse object.
- class splatnet3_scraper.query.QueryResponse
The QueryResponse class represents a response from the SplatNet 3 API. The class provides various convenience methods for interacting with the returned data and contains metadata about the response. The metadata contains the query that was used to get the data and the timestamp of the response. Additional metadata may be added in the future. Using the getitem method on the response will return another QueryResponse with the data from the key. If the data is a list, the getitem method will generate a QueryResponse for each item in the list. The QueryResponse class also provides a parse_json method that returns a JSONParser object for the response data. This is currently not used by the library, so it may be removed in the future.
- class splatnet3_scraper.query.Config
The Config class is used to load, store, and manage the configuration options for the QueryHandler class. The Config class has a number of static methods that are used to create a new instance of the class, including from a file, from a few default options, etc. The bulk of the configuration options are stored in a ConfigParser object for uniformity and ease of use. It also functions as a high-level wrapper around the
TokenManagerclass that enables theQueryHandlerclass to be quickly and easily instantiated, leading to less time spent configuring theQueryHandlerclass and more time spent making queries.
- class splatnet3_scraper.query.JSONParser
Class containing JSON methods for saving and loading data.