Module: nintendo.nnas

Provides a client for the 3DS/Wii U account server.

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

class NNASClient
The account server client.

def calc_password_hash(pid: int, password: str) -> str Calculates the password hash for hash-based authentication and returns the hexdigest.

NNASClient

def __init__()
Creates a new account server client.

def set_context(context: TLSContext) -> None
Changes the TLS context. By default, the server certificate is verified with Nintendo CA - G3, and Wii U Common Prod 1 is used as the client certificate.

def set_url(url: str) -> None
Changes the server to which requests are sent. The default is account.nintendo.net.

def set_client_id(client_id: str) -> None
Changes the content of the X-Nintendo-Client-ID header. The default is "a2efa818a34fa16b8afbc8a74eba3eda".

def set_client_secret(client_secret: str) -> None
Changes the content of the X-Nintendo-Client-Secret header. The default is "c91cdb5658bd4954ade78533a339cf9a".

def set_platform_id(platform_id: int) -> None
Changes the content of the X-Nintendo-Platform-ID header. The default is 1 (Wii U).

def set_device_type(device_type: int) -> None
Changes the content of the X-Nintendo-Device-Type header. The default is 2 (retail).

def set_fpd_version(version: int) -> None
Changes the content of the X-Nintendo-FPD-Version header. The default is 0.

def set_environment(environment: str) -> None
Changes the content of the X-Nintendo-Environment header. The default is "L1" (production).

def set_device(device_id: int, serial_number: str, system_version: int, cert: str = None) -> None
Changes the X-Nintendo-Device-ID, X-Nintendo-Serial-Number, X-Nintendo-System-Version and X-Nintendo-Device-Cert headers. By default, the system version is set to 0x260 and the other headers are omitted.

def set_locale(region: int, country: str, language: str) -> None
Changes the X-Nintendo-Region, X-Nintendo-Country and Accept-Language headers. By default, the region is 4 (Europe), the country is "NL" (Netherlands) and the language is "en" (English).

def set_title(title_id: int, title_version: int) -> None
Changes the X-Nintendo-Title-ID and X-Nintendo-Application-Version headers. The X-Nintendo-Unique-ID header is also derived from the title id. By default, these headers are omitted.

async def login(username: str, password: str, password_type: str = None) -> OAuth20
Logs in on the account server. This method must be called prior to any method that accesses your account data.

async def get_nex_token(access_token: str, game_server_id: int) -> NexToken
Requests a nex token for the given game server.

async def get_service_token(access_token: str, client_id: str) -> str
Requests an independent service token for the given client id.

async def get_profile(access_token: str) -> Profile
Requests your profile.

async def get_miis(pids: list[int]) -> list[Mii]
Requests the miis for the given user ids.

async def get_pids(nnids: list[str]) -> dict[str, int]
Requests the user ids for the given Nintendo Network IDs.

async def get_nnids(pids: list[int]) -> dict[int, str]
Requests the Nintendo Network IDs for the given user ids.

async def get_pid(nnid: str) -> int
Requests the user id for the given Nintendo Network ID.

async def get_nnid(pid: int) -> str
Requests the Nintendo Network ID for the given user id.

Account

domain: str
type: str
username: str

DeviceAttribute

created_date: datetime.datetime
name: str
value: str

Email

id: int
address: str
primary: bool
parent: bool
reachable: bool
type: str
validated: bool
validated_date: datetime.datetime

Mii

data: bytes
id: int
name: str
images: list[MiiImage]
primary: bool
pid: int
nnid: str

MiiImage

id: int
type: str
url: str
cached_url: str

NexToken

host: str
port: int
pid: int
password: str
token: str

OAuth20

token: str
refresh_token: str
expires_in: int

Profile

accounts: list[Account]
active_flag: bool
birth_date: datetime.datetime
country: str
create_date: datetime.datetime
device_attributes: list[DeviceAttribute]
forgot_pw_email_sent: datetime.datetime
gender: str
language: str
updated: datetime.datetime
marketing_flag: bool
off_device_flag: bool
pid: int
email: Email
mii: ProfileMii
region: int
temporary_password_expiration: datetime.datetime
tz_name: str
nnid: str
utc_offset: int

ProfileMii

id: int
name: str
data: bytes
primary: bool
status: str
hash: str
images: list[MiiImage]