Module: nintendo.switch.baas

Provides a client for the BaaS server.

class PresenceState
Provides predefined constants for the presence state.

class BAASError(Exception)
Raised when the BaaS server returns an error code.

class BAASClient
The BaaS client.

PresenceState

INACTIVE: str = "INACTIVE"
ONLINE: str = "ONLINE"
PLAYING: str = "PLAYING"

BAASError

response: HTTPResponse
type: str
name: str
title: str
detail: str
status: int
instance: str

BAASClient

def __init__()
Creates a new BaaS client.

def set_request_callback(callback: Callable) -> None
By default, requests are performed with http.request. This method lets you provide a custom callback instead.

def set_context(context: TLSContext) -> None
Changes the TLS context. By default, the server certificate is verified with default authorities.

def set_certificate(cert: TLSCertificate, key: TLSPrivateKey) -> None Changes the client certificate of the current TLS context. This is required on system version 21.0.0 and later, when m-lp1.baas.nintendo.com is contacted.

def set_host(host: str) -> None
Changes the server to which the HTTP requests are sent. By default, requests are sent to e0d67c509fb203858ebcb2fe3f88c2aa.baas.nintendo.com or m-lp1.baas.nintendo.com, depending on the system version.

def set_power_state(state: str) -> None
Changes the content of the X-Nintendo-PowerState header. The default is "FA".

def set_system_version(version: int) -> None
Changes the system version that is emulated by the client. The system version should be given as a decimal integer. For example, 1002 indicates system version 10.0.2. All system versions from 9.0.0 up to 22.1.0 are supported.

async def authenticate(device_token: str, penne_id: str = None) -> dict
Requests an authorization token with /1.0.0/application/token. This method must be called before any other requests can be made. The device token can be obtained from the dauth server.

The penneId parameter was added in system version 19.0.0.

async def login(id: int, password: str, access_token: str, app_token: str = None, na_country: str = None, skip_verification: bool = False, is_persistent: bool = True) -> dict
Logs in with the given user id and password, using /1.0.0/login. If an app token is provided, the server returns an id token that can be used to log in on a game server. App tokens can be obtained from the aauth server. If skip_verification is True the client asks the server to skip NSO verification.

The na_country parameter is required in system version 18.0.0 and later. The is_persistent parameter was added in system version 20.0.0.

async def register(access_token: str) -> dict
Registers a new device account on the BaaS server.

async def update_presence(user_id: int, device_account_id: int, access_token: str, state: str, title_id: int, presence_group_id: int, app_fields: dict[str, str] = {}, acd_index: int = 0) -> dict
Updates your presence state by patching /1.0.0/users/<id>/device_accounts/<id>.

async def get_friends(user_id: int, access_token: str, count: int = 300)
Requests your friend list with /2.0.0/users/<id>/friends.