Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

A Python wrapper for the Mojang API and Minecraft website

Project description

PyPI versionPython 3.6Python 3.7Python 3.8

<center>Read the DocsMIT LicenseDownloads



Mojang is a Python package for accessing Mojang's services. It serves as a wrapper around Mojang's API, authentication API, and some parts of the website.

It can be used to get name drop dates, convert UUIDs, change a Minecraft profile's skin, code name snipers, and much more.


Python 3.6 or higher is required.

To install the library, you can just run the following console command:

python -m pip install mojang

MojangAPI Quickstart

import time
from mojang import MojangAPI

uuid = MojangAPI.get_uuid("Notch")

if not uuid:
    print("Notch does not exist.")
    print("Notch's UUID is", uuid)
    profile = MojangAPI.get_profile(uuid)
    print("Notch's skin URL is", profile.skin_url)

servers = MojangAPI.get_blocked_servers()
print(f"There are {len(servers)} blocked servers on Minecraft.")

drop_timestamp = MojangAPI.get_drop_timestamp("Notch")

if not drop_timestamp:
    print("Notch is not dropping")
    seconds = drop_timestamp - time.time()
    print(f"Notch drops in {seconds} seconds")

For a complete list of functions, see the MojangAPI reference.

MojangUser Quickstart

To log into a Mojang account, you can import MojangUser and create a user object.

from mojang import MojangUser


# example attributes include
print( # account's user ID
print(user.dob) # account's date of birth

# access current session information

Completing security challenges

If the account has security questions and you're logging in from a new IP address, you must answer them to complete authentication and unlock access to all of Mojang's services. Otherwise, you will not be able to modify account data or access the Minecraft profile.

from mojang import MojangUser
from mojang.exceptions import SecurityAnswerError


if not user.is_fully_authenticated: 
    # print the security challenges if you need them

    # make a list of the 3 answers to send
    # make sure they are in the same order as the challenges
    # they are not case-sensitive
    answers = ["oreos", "blue", "phoenix"]

    # completes authentication
    # throws SecurityAnswerError if a question is incorrect
    except SecurityAnswerError:
        print("A security answer was answered incorrectly.")

If security challenges do not have to be answered, is_fully_authenticated will be set to True after logging in.

Logging in with a proxy

Simply pass a HTTPS proxy when creating a user object, and all of the session's requests will be routed through it:

user = MojangUser("YOUR_USERNAME", "YOUR_PASSWORD", proxy="")

NOTE: For proxies that require authentication (i.e., have a username and password), make sure they're in the following format: username:password@proxy:port


from mojang import MojangUser

proxy = "proxy_username:proxy_password@"

user = MojangUser("YOUR_USERNAME", "YOUR_PASSWORD", proxy=proxy)

Interacting with the account's Minecraft profile

Access the Minecraft profile through the profile object.


if not user.profile.is_name_change_allowed:
    print("Account does not have an available name change")
    print(f"It was last changed on {user.profile.name_changed_at}")

# also
# and many more!


# check if the profile has a skin first
    # some skin attributes include

# upload a skin from an image file and set it to slim or classic
file_path = "C:\\Users\\Summer\\Desktop\\skin.png"
user.profile.skin_upload("slim", file_path)

# delete the profile's skin and set the default one

# or even copy another player's skin!
uuid = MojangAPI.get_uuid("Notch")
user.profile.skin_copy(uuid) # now your account will have Notch's skin

# get a dictionary object of all the skin's information


if user.profile.capes:
    print(f"Found {len(user.profile.capes} capes on the profile")

# access them by index

# or just loop through
for cape in user.profile.capes:

Changing profile name

if not user.profile.change_name("Notch")
    print("Failed to change name to Notch")

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mojang, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size mojang-0.1.2-py3-none-any.whl (20.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size mojang-0.1.2.tar.gz (16.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page