mojang.api.session

mojang.api.session.change_user_name(access_token: str, name: str)

Change name of authenticated user

Parameters:
  • access_token (str) – The session access token

  • name (str) – The new user name

Raises:
  • Unauthorized – if the access token is invalid

  • InvalidName – if the new user name is invalid

  • UnavailableName – if the new user name is unavailable

Example:

>>> from mojang.account import session
>>> session.change_user_name("ACCESS_NAME", "NEW_NAME")
mojang.api.session.change_user_skin(access_token: str, path: str, variant='classic')

Change skin of authenticated user

Parameters:
  • access_token (str) – The session access token

  • path (str) – The the path to the new skin, either local or remote

Parama str variant:

The skin variant, either classic or slim

Raises:

Unauthorized – if the access token is invalid

Example:

>>> from mojang.account import session
>>> session.change_user_skin("ACCESS_TOKEN", "http://...")
mojang.api.session.check_product_voucher(access_token: str, voucher: str) bool

Check if a voucher is available.

Parameters:
  • access_token (str) – The session access token

  • voucher (str) – The code you want to check

Raises:
  • Unauthorized – if the access token is invalid

  • ValueError – if the voucher is not a real code

Example:

>>> from mojang.api import session
>>> session.check_product_voucher("ACCESS_TOKEN", "JHRD2-HWGTY-WP3MW-QR4MC-CGGHZ")
True
mojang.api.session.check_username(access_token: str, username: str) bool

Check if username is available

Caution

This endpoint is limited, the function will return a RuntimeError if you sent too many requests.

Parameters:
  • access_token (str) – The session access token

  • username (str) – The username you want to checkt

Raises:
  • Unauthorized – if the access token is invalid

  • RuntimeError – if you sent to many requests

mojang.api.session.get_profile(access_token: str) AuthenticatedUserProfile

Returns the full profile of a authenticated user

Parameters:

access_token (str) – The session access token

Raises:

Unauthorized – if the access token is invalid

mojang.api.session.get_user_name_change(access_token: str) NameChange

Return if user can change name and when it was created

Parameters:

access_token (str) – The session access token

Raises:

Unauthorized – if the access token is invalid

Example:

>>> from mojang.account import session
>>> session.get_username_change("ACCESS_TOKEN")
NameChange(allowed=True, created_at=datetime.datetime(2006, 4, 29, 10, 10, 10))
mojang.api.session.hide_user_cape(access_token: str)

Hide user cape

Parameters:

access_token (str) – The session access token

Raises:

Unauthorized – if the access token is invalid

Example:

>>> from mojang.account import session
>>> session.hide_user_cape("ACCESS_TOKEN")
mojang.api.session.owns_minecraft(access_token: str, verify_sig: bool = False, public_key: str | None = None) bool

Returns True if the authenticated user owns minecraft

Parameters:
  • access_token (str) – The session access token

  • verify_sig (str) – If True, will check the jwt sig with the public key

  • public_key (str) – The key to use to verify jwt sig

Raises:

Unauthorized – if the access token is invalid

Example:

>>> from mojang.account import session
>>> session.owns_minecraft("ACCESS_TOKEN")
True
mojang.api.session.redeem_product_voucher(access_token: str, voucher: str) bool

Redeem a product voucher gift code. Returns True if the code was redeemed

Parameters:
  • access_token (str) – The session access token

  • voucher (str) – The code you want to redeem

Raises:
  • Unauthorized – if the access token is invalid

  • ValueError – if the voucher is not a real code

Example:

>>> from mojang.api import session
>>> session.redeem_product_voucher("ACCESS_TOKEN", "JHRD2-HWGTY-WP3MW-QR4MC-CGGHZ")
True
mojang.api.session.reset_user_skin(access_token: str)

Reset skin of authenticated user

Parameters:

access_token (str) – The session access token

Raises:

Unauthorized – if the access token is invalid

Example:

>>> from mojang.account import session
>>> session.reset_user_skin("ACCESS_TOKEN", "USER_UUID")
mojang.api.session.show_user_cape(access_token: str, cape_id: str)

Show user cape

Parameters:

access_token (str) – The session access token

Raises:

Unauthorized – if the access token is invalid

Example:

>>> from mojang.account import session
>>> session.show_user_cape("ACCESS_TOKEN")