2.0.1Type: Object
(String)
: user UUID
(String)
(String)
(String)
(String)
(String)
(String)
(Number)
(Number)
(Number)
(Number)
(Boolean)
(Boolean)
(Boolean)
(Boolean)
(Boolean)
(Boolean)
(Boolean)
(String)
(Boolean)
(Boolean)
Type: Object
Type: Object
Type: Object
Type: Object
Returns status of various Mojang services in a more helpful format.
Promise<Array>:
resolves a list like
[{hostname, color, isAvailable, hasIssues}]
Undocumented: Gets profile data for the given profile UUID.
(String)
profile UUID (does not work with user UUID)
Promise<Object>:
resolves with
{id, name, legacy?, demo?}
Gets all name changes for a given player's profile UUID.
(String)
profile UUID (does not work with user UUID)
Promise<Array<{name: String, changedToAt: Number}>>:
resolves if profile exists
Gets a list of abbreviated game profiles from the list of profile names.
It seems results are reordered alphabetically.
You cannot request more than 100 names per request.
(String?
= 'minecraft')
game agent to search within (minecraft, scrolls)
Promise<Array>:
resolves with
[{id, name, legacy?, demo?}]
async function getPaidMinecraftProfiles (names) {
const list = await getProfiles(names)
return list.filter(({demo}) => !demo)
}
Gets an abbreviated game profile at a given timestamp for an IGN name.
Prefer lookupProfiles when looking up current data.
(String)
current profile name (IGN) of the user
(Number?)
UNIX timestamp to check the username at
(String?
= 'minecraft')
game agent to check against
Promise<Object>:
resolves with
{id, name, legacy?, demo?}
const {id, name, legacy, demo} = await lookupProfileAt('Notch', 1503335853700)
Get statistics on the sales of Minecraft.
Promise<Array<{total: Number, last24: Number, saleVelocityPerSeconds: Number}>>:
resolves if metricKeys is provided
Authenticates a user with their Mojang credentials.
Use agent if session is for a game client, ie. a Minecraft launcher.
Handle access tokens securely, but they do invalidate easily.
(Object)
the payload of the auth request
| Name | Description |
|---|---|
credentials.username String
|
email or username of a Mojang account |
credentials.password String
|
password for the given account |
credentials.clientToken String?
|
if empty, server will generate a client token |
credentials.agent Object?
|
if valid, adds
selectedProfile
to response
|
credentials.agent.name String
|
name of the agent ('Minecraft' or 'Scrolls') |
credentials.agent.version Number
|
version number of the agent (use
1
)
|
Promise<MojangSession>:
resolves if credentials are valid
const clientToken = 'loaded from settings'
const agent = {name: 'Minecraft', version: 1}
const session = await mojang.authenticate({username, password, clientToken, agent})
console.debug('access token', session.accessToken)
console.debug('profile id', session.selectedProfile.id)
console.debug('minecraft ign', session.selectedProfile.name)
console.debug('user id', session.user.id)
Checks if an access token is suitable for use with a Minecraft server.
Promise<Boolean>:
resolves true if tokens are valid
if (await mojang.isValid(session)) {
console.debug('access token still good')
} else {
console.debug('access token has gone bad')
}
Refreshes a given access token. May work on invalid access tokens (about 1 token back in time).
(Object)
a session access token
| Name | Description |
|---|---|
session.accessToken String
|
a session access token |
session.clientToken String?
|
must match the one used to obtain the access token |
session.selectedProfile Object?
|
use only with access tokens that were not assigned a game profile |
session.selectedProfile.id String
|
profile UUID |
session.selectedProfile.name String
|
profile name (IGN) |
Promise<MojangSession>:
resolves if the Mojang gods are feeling generous
if (!await mojang.isValid(session)) {
const nextSession = await mojang.refresh(session)
}
Invalidate an access token.
Promise:
always resolves, regardless if tokens were valid
const session = await mojang.authenticate(credentials)
console.log('logged in', session.selectedProfile.name)
await mojang.invalidate(session)
console.log('logged out')
Invalidates access tokens of a given Mojang account.
Promise:
resolves only if credentials were correct
mojang.signout({username, password})
.then(() => console.log('user signed out'))
.catch(err => console.error(err))
Undocumented: Gets a logged-in user's IP security status for the current IP.
Promise<Boolean>:
resolves true if current IP is secure
const canChangeSkins = await isSecure(accessToken)
Undocumented: Gets a logged-in user's security challenge questions.
Promise<Array<MojangChallenge>>:
resolves if access token is valid
Undocumented: Submits a logged-in user's security challenge answers to trust the current IP.
(Object)
object from authentication
| Name | Description |
|---|---|
session.accessToken String
|
valid access token for the user's account |
Promise:
resolves if location was secured
const challenges = await getChallenges(session)
const answers = await Promise.all(challenges.map(async c => {
const answer = await prompt(c.question.question)
return {id: c.answer.id, answer}
}))
await answerChallenges(session, answers) // might throw
await isSecure(session) // true if successful
A special service that returns a profile's name, skin URL, and cape URL.
This endpoint is used by the official launcher to load the current skin.
Rate limit: You can request the same profile once per minute.
(String)
profile UUID of a player
Promise<CustomSession>:
resolves if profile exists
Returns a list of SHA1 hashes used to check server addresses against when the client tries to connect.
See http://wiki.vg/Mojang_API#Blocked_Servers for how this list is used.
Promise<Array<String>>:
resolves to a list of address hashes
Gets a logged-in user's private Mojang account information.
Promise<MojangUser>:
resolves if access token is valid
Sets a logged-in user's in-game skin to an online image.
(Object)
object from authentication
| Name | Description |
|---|---|
session.accessToken String
|
valid access token for the user's account |
(String)
which profile UUID to update the skin of
(String)
Internet-accessible URL of the image file
(Boolean?
= false)
if true, the slim model will be used with the skin
Promise:
resolves if access token, profile UUID, and skin URL are valid
Resets/deletes a logged-in user's in-game skin.
(Object)
object from authentication
| Name | Description |
|---|---|
session.accessToken String
|
valid access token for the user's account |
(String)
which profile UUID to update the skin of
Promise:
resolves if skin was deleted/reset
Undocumented: Gets a list of all of a logged-in user's game profiles.
Promise<Array<MojangProfile>>:
resolves if access token is valid
Undocumented: Gets a logged-in user's capes for a given profile.
I have no idea what this endpoint returns!
(Object)
object from authentication
| Name | Description |
|---|---|
session.accessToken String
|
valid access token for the user's account |
(String)
game profile UUID to look for capes in
Promise<Array>:
resolves with an array of something