prismarine-realms
Minecraft Realm interface for Minecraft Java and Bedrock editions, providing a stable API to start/stop Realms, and obtain Realm information such as connection addresses.
Minecraft Realms is a subscription based service provided by Mojang where users can host, create and manage their own private Minecraft servers.
Installation
npm install prismarine-realms
Usage
RealmAPI
.from(authflow: Authflow, platform: 'bedrock' | 'java')
Takes an Authflow instance from prismarine-auth, you can see the documentation for this here.
API
Definitions
Param | Type | Description |
---|
realmId | string | The ID of the Realm |
realmInviteCode | string | The invite code for the Realm. This can be used an unlimited amount of times and allows anyone with the code to join the Realm (Only on Bedrock) |
invitationId | string | The ID of the invitation. This can only be used by the player it is sent to and expires after use (Only on Bedrock) |
username | string | The username of player |
uuid | string | The unique ID of the player, without hyphens |
xuid | string | The Xbox User ID of the targeted player |
const { Authflow } = require('prismarine-auth')
const { RealmAPI } = require('prismarine-realms')
const authflow = new Authflow()
const api = RealmAPI.from(authflow, 'bedrock')
getRealms(): Promise<Realm[]>
Returns a list of Realms the authenticating account has joined or owns.
await api.getRealms()
getRealm(realmId: string): Promise
Gets detailed information about a Realm if owned
await api.getRealm('1234567')
getRealmFromInvite(realmInviteCode: string, invite: boolean): Promise
(Bedrock Edition Only) Gets detailed information about a Realm from the invite code and adds it to the authenticating accounts Realms list if not present. If invite is false, the Realm will not be added to the authenticating accounts Realms list.
await api.getRealmFromInvite('AB1CD2EFA3B')
getRealmInvite(realmId: string): Promise
(Bedrock Edition Only) Gets the invite code for a Realm
await api.getRealmInvite('1234567')
refreshRealmInvite(realmId: string): Promise
(Bedrock Edition Only) Refreshes the invite code for a Realm (Note: This will invalidate the previous invite code)
await api.refreshRealmInvite('1234567')
getPendingInviteCount(): Promise
(Bedrock Edition Only) Gets the number of pending invites for the authenticating account
await api.getPendingInviteCount()
getPendingInvites(): Promise<RealmPlayerInvite[]>
(Bedrock Edition Only) Gets a list of pending invites for the authenticating account
await api.getPendingInvites()
acceptRealmInvitation(invitationId: string): Promise
(Bedrock Edition Only) Accepts a pending invite for the authenticating account
await api.acceptRealmInvitation('1234567')
rejectRealmInvitation(invitationId: string): Promise
(Bedrock Edition Only) Rejects a pending invite for the authenticating account
await api.rejectRealmInvitation('1234567')
getAddress(): Promise<{ host, port }>
Gets the address for the Realm.
const realm = await api.getRealm('1234567')
await realm.getAddress()
invitePlayer(uuid: string, name: string): Promise
Invites a player to the Realm
const realm = await api.getRealm('1234567')
await realm.invitePlayer('a8005260a332457097a50bdbe48a9a21', 'Steve')
open(): Promise
Opens a Realm. Allows players to join
const realm = await api.getRealm('1234567')
await realm.open()
close(): Promise
Closes a Realm. Removes all current players and restricts joining
const realm = await api.getRealm('1234567')
await realm.close()