This page provides documentation for '''API''' endpoints provided by [[Mojang Studios]] which allows user to query player data and make changes programmatically.
Currently, the API is rate limited at 600 requests per 10 minutes. http://wiki.vg/Mojang_API ([https://web.archive.org/web/20241129034336/wiki.vg/Mojang_API Internet Archive])
== Request and response ==
For requests with a payload, the following restrictions apply:
* Request must include the Content-Type
header, which must be application/json. Otherwise, the server returns HTTP 415.
* Payload must be a valid json. Otherwise, the server returns HTTP 400.
If the request is successful, the server:
* Returns a successful response code (HTTP 2XX)
* Returns an empty payload (with HTTP 204) or a valid json
Otherwise, if the request fails, the server returns a non-2XX HTTP status code with this payload:
Authorization
header or the token is invalid.
|-
| Unauthorized
| The request requires user authentication
| Endpoint requires authentication, but request header does not have an Authorization
header.
|-
| rowspan=2 | 403
| ForbiddenOperationException
| Forbidden
| Invalid auth token.
|-
| {{tc|n/a}}
| Your account has been suspended. Please contact customer service.
| Account has been banned/suspended state by triggering a high volume of erroneous requests. See [[#Account suspensions]].
|-
| 404
| Not Found
| The server has not found anything matching the request URI
| Endpoint does not exist.
|-
| 405
| Method Not Allowed
| The method specified in the request is not allowed for the resource identified by the request URI
| Request method is not supported.
|-
| 415
| Unsupported Media Type
| The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method
| {{cd|Content-Type}} request header does not match the type the endpoint allows.
|}
=== Account suspensions ===
A Minecraft account can be entered into a banned/suspended state by triggering a high volume of erroneous requests, such as a high volume of 429s while uploading a skin.
These suspensions appear to be temporary, although this is speculation and the exact functionality of this automatic suspension system is unknown.
POST https://api.mojang.com/users/profiles/minecraft/ <''player name''>
; Response
https://api.mojang.com/users/profiles/minecraft/jeb_
https://api.mojang.com/profiles/minecraft
* https://api.minecraftservices.com/minecraft/profile/lookup/bulk/byname
; Response
["jeb_","notch"]
.
https://sessionserver.mojang.com/session/minecraft/profile/ <''UUID''>
orhttps://sessionserver.mojang.com/session/minecraft/profile/ <''UUID''>?unsigned=false
; Response
textures
.
*** {{Nbt|string|signature}}: Signature signed with Yggdrasil private key as Base64 string, only exists when unsigned=false
.
*** {{Nbt|string|value}}: [[wikipedia:Base64|Base64]] string with all player textures (skin and cape). The decoded string includes:
**** {{Nbt|compound}} Texture object.
***** {{Nbt|int|timestamp}}: [[wikipedia:Unix time|Unix time]] in milliseconds the texture is accessed.
***** {{Nbt|string|profileId}}: Player's UUID without dashes.
***** {{Nbt|string|profileName}}: Player name.
***** {{Nbt|boolean|signatureRequired}}: Only exists when unsigned=false
.
***** {{Nbt|compound|textures}}: Texture.
****** {{Nbt|compound|SKIN}}: [[Skin]] texture. This does not exist if the player does not have a custom skin.
******* {{Nbt|string|url}}: URL to the skin texture.
******* {{Nbt|compound|metadata}}: Optional. Metadata for the skin.
******** {{Nbt|string|model}}: slim
. Only exists when skin model is Alex. When skin model is Steve, this metadata does not exist.
****** {{Nbt|compound|CAPE}}: [[Cape]] texture. If the player does not have a cape, this does not exist.
******* {{Nbt|string|url}}: URL to the cape texture.
https://sessionserver.mojang.com/session/minecraft/profile/853c80ef3c3749fdaa49938b674adae6
RPS
.
*** {{Nbt|string|SiteName}}: Website name. This should be user.auth.xboxlive.com
.
*** {{Nbt|string|RpsTicket}}: Ticket used for logging in. Value should be d=<''Microsoft access token''>
.
** {{Nbt|string|RelyingParty}}: Replying party. This should be http://auth.xboxlive.com
.
** {{Nbt|string|TokenType}}: Type of the access token. This should be JWT
.
https://user.auth.xboxlive.com/user/authenticate
SSL renegotiation required in SSL implementation.
; Response
RETAIL
.
*** {{Nbt|list|UserTokens}}: User's Xbox Live token.
**** {{Nbt|string}}: User's Xbox Live token obtained in the previous step.
** {{Nbt|string|RelyingParty}}: Replying party. This should be rp://api.minecraftservices.com/
.
** {{Nbt|string|TokenType}}: Type of the access token. This should be JWT
.
https://xsts.auth.xboxlive.com/xsts/authorize
SSL renegotiation required in SSL implementation.
; Response
XBL3.0 x=<''User hashcode''>;<''XSTS access token''>
.
https://api.minecraftservices.com/authentication/login_with_xbox
; Response
Bearer
.
** {{Nbt|string|expires_in}}: Time period until the token expires in seconds.
Authorization
should be Bearer <''Minecraft access token''>
.
; Request (GET)
https://api.minecraftservices.com/entitlements/mcstore
; Response
If the account owns Minecraft, returns:
product_minecraft
or game_minecraft
.
*** {{Nbt|string|signature}}: JWT signature for the data.
** {{Nbt|string|signature}}: JWT signature.
** {{Nbt|string|keyID}}: Unknown.
https://api.minecraftservices.com
, and all requires the Authorization
header in request with value Bearer <''Minecraft access token''>. HTTP 401 is returned if token is missing or invalid.
=== Query player profile ===
; Request (GET)
/minecraft/profile
; Response
CLASSIC
for the Steve model and SLIM
for the Alex model.
** {{Nbt|list|capes}}: A list of info of all the capes the player owns.
*** {{Nbt|compound}}: A cape.
**** {{Nbt|string|id}}: Cape's UUID.
**** {{Nbt|string|state}}: Usage status for the cape.
**** {{Nbt|string|url}}: URL to the cape.
**** {{Nbt|string|alias}}: Alias for the cape.
/player/attributes
; Response
MULTIPLAYER
exists.
***** {{Nbt|string|banId}}: UUID of the ban.
***** {{Nbt|string|expires}}: When the ban expires. This does not exist if the player is permanently banned.
***** {{Nbt|string|reason}}: Reason for the ban.
***** {{Nbt|string|reasonMessage}}: Ban message displayed.
/player/attributes
; Response
The same as [[#Query player attributes]].
=== Get list of blocked users ===
; Request (GET)
/privacy/blocklist
; Response
/player/certificates
; Response
/minecraft/profile/namechange
; Response
/productvoucher/giftcode
; Response
Returns HTTP 200 or 204 if the gift code is valid. Otherwise returns HTTP 404.
=== Check name availability ===
; Request (GET)
/minecraft/profile/name/<''name to be checked''>/available
; Response
DUPLICATE
means the name is taken. AVAILABLE
means the name is available.NOT_ALLOWED
means the name does not meet requirements.
/minecraft/profile/name/<''name to change to''>
; Response
CLASSIC
for the Steve model and SLIM
for the Alex model.
** {{Nbt|list|capes}}: A list of info of all the capes the player owns.
*** {{Nbt|compound}}: A cape.
**** {{Nbt|string|id}}: Cape's UUID.
**** {{Nbt|string|state}}: Usage status for the cape.
**** {{Nbt|string|url}}: URL to the cape.
**** {{Nbt|string|alias}}: Alias for the cape.
detail.status
is DUPLICATE, the name has already been taken.
|-
| 429
| -
| -
| To many rename requests sent.
|}
=== Change skin ===
; Payload
classic
for the Steve model and slim
for the Alex model.
** {{Nbt|string|url}}: URL to the skin.
/minecraft/profile/skins
; Response
Returns empty payload if operation succeeds.
=== Upload skin ===
; Payload
Payload is made up of two parts:
* {{cd|variant}}: Skin variant. classic
for the Steve model and slim
for the Alex model.
* {{cd|file}}: Image data for the new skin. See example below.
; Request (POST)
/minecraft/profile/skins
; Example
https://api.mojang.com/user/profile/ <''UUID''>/skin
; Response
Returns empty payload if reset succeeds.
=== Hide cape ===
; Request (DELETE)
/minecraft/profile/capes/active
; Response
Returns empty payload if operation succeeds.
=== Show cape ===
; Payload
/minecraft/profile/capes/active
; Response
CLASSIC
for the Steve model and SLIM
for the Alex model.
** {{Nbt|list|capes}}: A list of info of all the capes the player owns.
*** {{Nbt|compound}}: A cape.
**** {{Nbt|string|id}}: Cape's UUID.
**** {{Nbt|string|state}}: Usage status for the cape.
**** {{Nbt|string|url}}: URL to the cape.
**** {{Nbt|string|alias}}: Alias for the cape.
https://sessionserver.mojang.com/blockedservers
; Response
A text file where every line is the SHA-1 hash of a blocked server. Servers that are known to be blocked can be found at [https://github.com/Reecepbcups/FollowTheEULA/blob/master/blockedServersList.txt here].
=== Verify login session on client ===
; Payload
https://sessionserver.mojang.com/session/minecraft/join
; Response
Returns HTTP 204 if authentication passes.
=== Verify login session on server ===
; Input
Case insensitive player name, server ID obtained by the above algorithm and the client IP (optional).
; Request (GET)
https://sessionserver.mojang.com/session/minecraft/hasJoined? username=<''player name''>&serverId=<''Server ID''>&ip=<''Client IP''>
; Response
Returns [[#Query player's skin and cape|this payload]] if verification passes.
== History ==
{{HistoryTable
|{{HistoryLine||April 14, 2014|link=https://github.com/Mojang/AccountsClient|Mojang API is released.}}
|{{HistoryLine||November 2020|link=https://bugs.mojang.com/browse/WEB-3367|Endpoint for obtaining player UUID no longer supports the {{cd|at}} parameter.}}
|{{HistoryLine||October 8, 2021|link=https://bugs.mojang.com/browse/WEB-2303?focusedCommentId=1086543&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-1086543|Endpoint for querying Mojang API status is removed. The endpoint was https://status.mojang.com/check
.}}
|{{HistoryLine||May 8, 2022|link={{tweet|Mojang_Ined|1501541417784852484}}|Endpoint for querying Minecraft sales is removed. The endpoint was https://api.mojang.com/orders/statistics
.}}
|{{HistoryLine||September 13, 2022|link=https://help.minecraft.net/hc/en-us/articles/8969841895693-Username-History-API-Removal-FAQ-|The endpoint for querying names a player used to use is removed. The endpoint was https://api.mojang.com/user/profiles/ <''UUID''>/names
.}}
}}
== References ==
This article is partially adapted from [[Special:PermaLink/2777487|Mojang API]] on wiki.vg.
== Examples ==
* [https://github.com/hawezo/MojangSharp C#] - Full API wrapper
* [https://github.com/CmlLib/MojangAPI C#] - Full API wrapper with Mojang/Microsoft Authentication
* [https://github.com/spnda/dart_minecraft Dart] - Almost full API wrapper with Mojang Authentication
* [https://github.com/Lukaesebrot/mojango Go] - Full API wrapper
* [https://github.com/PhilipBorgesen/minecraft/tree/master/profile Go] - UUIDs or names to profiles with skins, capes and name histories
* [https://github.com/summer/mojang Python] - Full API Wrapper. Also supports authentication & parts of the Minecraft website
* [https://github.com/Lucino772/pymojang Python] - Pymojang is a full wrapper around de Mojang API and Mojang Authentication API. Also support RCON, Query and Server List Ping
* [https://github.com/SynchronousX/mojang-api Python] - Full API wrapper (not updated since 2018)
* [https://github.com/techkid6/AccountsClientPython Python] - UUIDs or names to profiles (not updated since 2018)
* [https://github.com/elyby/mojang-api PHP] - Complete Mojang's API wrapper
* [https://github.com/Davidoc26/mojang-api PHP] - Almost full API wrapper with Mojang Authentication. Also support head rendering
* [https://github.com/MineTheCube/MojangAPI PHP] - UUIDs or names to profiles with skins, heads and name histories
* [https://gist.github.com/ezfe/a71feccd3a837a2592f1 PHP] - UUIDs to names
* [https://github.com/ozzyfant/AccountsClientPHP PHP] - UUIDs to names, names to uuids
* [https://github.com/SparklingComet/java-mojang-api Java] - Almost full API Wrapper
* [https://github.com/dpkgsoft/mojang Java] - Almost full API Wrapper with auth
* [https://github.com/novastosha/NMoyang Java] - Almost full API with Mojang Authentication and can also work as a console Application.
* [https://github.com/thechunknetwork/mojang-api JavaScript] - UUIDs or names to profiles with skins, capes and name histories
== References ==
{{reflist}}
== Navigation ==
{{Navbox Java Edition technical|General}}
[[Category:Java Edition protocol]]
{{license wiki.vg}}
[[de:Mojang API]]
[[zh:Mojang API]]