Skip to main content

SDK Methods Reference

Complete reference for all Moitribe JavaScript SDK methods, grouped by feature area for easy navigation.

Core Methods

init

Initialize the SDK with your game configuration.

MoitribeSDK('my-game-id', 'init', {
noui: true,
playerid: 'existing-player-id', // optional
channelid: 'my-channel', // optional
loginCallback: (result) => {
console.log('Login result:', result);
}
}, (result) => {
console.log('SDK initialized:', result);
});

Parameters:

  • noui (boolean): Disable UI components (required)
  • playerid (string, optional): Existing player ID for re-authentication
  • channelid (string, optional): Channel identifier
  • loginCallback (function, optional): Callback for login events
  • connectionCallbacks (object, optional): Connection state callbacks

isAuthenticated

Check if the current player is authenticated.

MoitribeSDK('my-game-id', 'isAuthenticated', {}, (result) => {
if (result.success) {
console.log('Player is authenticated');
} else {
console.log('Player not authenticated');
}
});

Authentication Methods

genOtp

Generate a one-time password for email or phone authentication.

MoitribeSDK('my-game-id', 'genOtp', {
emailid: 'player@example.com',
// OR
phno: '+1234567890'
}, (result) => {
console.log('OTP generated:', result);
});

Parameters:

  • emailid (string): Email address for OTP
  • phno (string): Phone number for OTP
  • callback (function): Response callback

loginWithOtp

Authenticate using the OTP sent to email or phone.

MoitribeSDK('my-game-id', 'loginWithOtp', {
emailid: 'player@example.com',
otp: '123456',
// OR
phno: '+1234567890',
otp: '123456'
}, (result) => {
console.log('Login result:', result);
});

Parameters:

  • emailid (string): Email address
  • phno (string): Phone number
  • otp (string): One-time password
  • callback (function): Response callback

createWithOtp

Create a new account using OTP verification.

MoitribeSDK('my-game-id', 'createWithOtp', {
emailid: 'newplayer@example.com',
otp: '123456',
name: 'Player Name',
// OR
phno: '+1234567890',
otp: '123456',
name: 'Player Name'
}, (result) => {
console.log('Account created:', result);
});

Parameters:

  • emailid (string): Email address
  • phno (string): Phone number
  • otp (string): One-time password
  • name (string): Player's display name
  • callback (function): Response callback

loginWithSocial

Authenticate using social platforms (Google, Facebook).

MoitribeSDK('my-game-id', 'loginWithSocial', {
social: {
socialplat: 'google', // or 'facebook'
id: 'social-user-id',
name: 'Player Name',
email: 'player@example.com',
picture: 'https://example.com/avatar.jpg'
}
}, (result) => {
console.log('Social login result:', result);
});

Parameters:

  • social (object): Social login credentials
    • socialplat (string): Platform ('google' or 'facebook')
    • id (string): Social platform user ID
    • name (string, optional): User's name
    • email (string, optional): User's email
    • picture (string, optional): Profile picture URL
  • callback (function): Response callback

Profile Methods

updateProfile

Update the authenticated player's profile information.

MoitribeSDK('my-game-id', 'updateProfile', {
name: 'New Display Name',
// Other profile fields as needed
}, (result) => {
console.log('Profile updated:', result);
});

Parameters:

  • Profile fields to update (name, email, etc.)
  • callback (function): Response callback

Leaderboard Methods

loadleaderboardmetadata

Load metadata for leaderboards configured in your game.

MoitribeSDK('my-game-id', 'loadleaderboardmetadata', {
onlyData: true
}, (result) => {
console.log('Leaderboard metadata:', result);
});

Parameters:

  • onlyData (boolean): Return data only (recommended)
  • callback (function): Response callback with LeaderboardMeta array

loadleaderboardtopscores

Retrieve top scores from a specific leaderboard.

MoitribeSDK('my-game-id', 'loadleaderboardtopscores', {
leaderboardid: 'high-scores',
collection: 1, // 0 for Social, 1 for All
timespan: 0, // 0 for All-time, 1 for Weekly, 2 for Daily
maxresults: 50,
onlyData: true
}, (result) => {
console.log('Top scores:', result);
});

Parameters:

  • leaderboardid (string): Leaderboard ID
  • collection (number): 0 (Social) or 1 (All players)
  • timespan (number): 0 (All-time), 1 (Weekly), 2 (Daily)
  • maxresults (number): Maximum number of results to return
  • onlyData (boolean): Return data only (recommended)
  • callback (function): Response callback with LeaderboardScoreData array

submitscore

Submit a score to a leaderboard.

MoitribeSDK('my-game-id', 'submitscore', {
leaderboardid: 'high-scores',
score: 1500,
scoretag: 'level-5-completed'
}, (result) => {
console.log('Score submitted:', result);
});

Parameters:

  • leaderboardid (string): Leaderboard ID
  • score (number): Score value to submit
  • scoretag (string, optional): Metadata tag for the score
  • callback (function): Response callback

Real-Time Multiplayer - Standard Rooms

createstandardroom

Create a standard RTM room with fixed player count.

MoitribeSDK('my-game-id', 'createstandardroom', {
variant: 1,
min_automatch_players: 2,
max_automatch_players: 4,
exclusive_bitmask: '15',
onRoomCreated: (status, room) => {
console.log('Room created:', status, room);
},
onMessageReceived: (messageData, senderParticipantID, isReliable) => {
console.log('Message received:', messageData);
}
}, (result) => {
console.log('Create room initiated:', result);
});

Parameters:

  • variant (number): Room variant defined by developer
  • min_automatch_players (number): Minimum players for auto-match
  • max_automatch_players (number): Maximum players for auto-match
  • exclusive_bitmask (string): 8-bit mask for player roles
  • retryTime (number, optional): Reconnection timeout in seconds
  • RTM callbacks (see Callbacks Reference)

joinstandardroominvcode

Join a standard room using invitation code.

MoitribeSDK('my-game-id', 'joinstandardroominvcode', {
invitationID: 'room-invitation-code',
onJoinedRoom: (status, room) => {
console.log('Joined room:', status, room);
}
}, (result) => {
console.log('Join room initiated:', result);
});

Parameters:

leavestandardroom

Leave a standard room.

MoitribeSDK('my-game-id', 'leavestandardroom', {}, (result) => {
console.log('Leave room initiated:', result);
});

standardmessagetoall

Send a message to all players in the standard room.

const gameData = new ArrayBuffer(4);
const view = new DataView(gameData);
view.setUint32(0, 42, true); // Game-specific data

MoitribeSDK('my-game-id', 'standardmessagetoall', {
messageData: gameData,
reliable: true
}, (result) => {
console.log('Message sent to all:', result);
});

Parameters:

  • messageData (ArrayBuffer): Message data
  • reliable (boolean): Message reliability (true for reliable, false for unreliable)

standardmessage

Send a message to a specific player in the standard room.

MoitribeSDK('my-game-id', 'standardmessage', {
messageData: gameData,
participantID: 'participant-123',
reliable: true
}, (result) => {
console.log('Message sent to player:', result);
});

Parameters:

  • messageData (ArrayBuffer): Message data
  • participantID (string): Target participant ID
  • reliable (boolean): Message reliability

standardmessagetogameserver

Send a message to the game server in standard room.

MoitribeSDK('my-game-id', 'standardmessagetogameserver', {
messageData: gameData,
reliable: true
}, (result) => {
console.log('Message sent to server:', result);
});

Real-Time Multiplayer - Endless Rooms

createendlessroom

Create an endless RTM room with variable player count.

MoitribeSDK('my-game-id', 'createendlessroom', {
variant: 1,
max_players: 20,
max_automatch_players: 10,
exclusive_bitmask: '15',
onRoomCreated: (status, room) => {
console.log('Endless room created:', status, room);
}
}, (result) => {
console.log('Create endless room initiated:', result);
});

Parameters:

  • variant (number): Room variant defined by developer
  • max_players (number): Maximum players allowed
  • max_automatch_players (number): Maximum auto-match players
  • exclusive_bitmask (string): 8-bit mask for player roles
  • retryTime (number, optional): Reconnection timeout in seconds
  • RTM callbacks (see Callbacks Reference)

joinendlessroominvcode

Join an endless room using invitation code.

MoitribeSDK('my-game-id', 'joinendlessroominvcode', {
invitationID: 'endless-room-code',
onJoinedRoom: (status, room) => {
console.log('Joined endless room:', status, room);
}
}, (result) => {
console.log('Join endless room initiated:', result);
});

leaveendlessroom

Leave an endless room.

MoitribeSDK('my-game-id', 'leaveendlessroom', {}, (result) => {
console.log('Leave endless room initiated:', result);
});

endlessmessagetoall

Send a message to all players in the endless room.

MoitribeSDK('my-game-id', 'endlessmessagetoall', {
messageData: gameData,
reliable: false // Use unreliable for frequent updates
}, (result) => {
console.log('Endless message sent to all:', result);
});

endlessmessage

Send a message to a specific player in the endless room.

MoitribeSDK('my-game-id', 'endlessmessage', {
messageData: gameData,
participantID: 'participant-456',
reliable: true
}, (result) => {
console.log('Endless message sent to player:', result);
});

endlessmessagetogameserver

Send a message to the game server in endless room.

MoitribeSDK('my-game-id', 'endlessmessagetogameserver', {
messageData: gameData,
reliable: true
}, (result) => {
console.log('Endless message sent to server:', result);
});

Tournament Methods

groupTournamentMeta

Get metadata for available group tournaments.

MoitribeSDK('my-game-id', 'groupTournamentMeta', {}, (result) => {
console.log('Tournament metadata:', result);
});

groupTournamentData

Get specific tournament data.

MoitribeSDK('my-game-id', 'groupTournamentData', {
tournamentid: 'tournament-123',
subtournamentid: 'sub-456' // optional
}, (result) => {
console.log('Tournament data:', result);
});

Parameters:

  • tournamentid (string): Tournament ID
  • subtournamentid (string, optional): Sub-tournament ID
  • callback (function): Response callback

groupTournamentJoin

Join a group tournament.

MoitribeSDK('my-game-id', 'groupTournamentJoin', {
tournamentid: 'tournament-123'
}, (result) => {
console.log('Joined tournament:', result);
});

Parameters:

  • tournamentid (string): Tournament ID
  • callback (function): Response callback

groupTournamentScoreSubmit

Submit score for a tournament.

MoitribeSDK('my-game-id', 'groupTournamentScoreSubmit', {
tournamentid: 'tournament-123',
subtournamentid: 'sub-456',
score: 2500
}, (result) => {
console.log('Tournament score submitted:', result);
});

Parameters:

  • tournamentid (string): Tournament ID
  • subtournamentid (string, optional): Sub-tournament ID
  • score (number): Score to submit
  • callback (function): Response callback

groupTournamentResults

Get tournament results.

MoitribeSDK('my-game-id', 'groupTournamentResults', {
tournamentid: 'tournament-123',
subtournamentid: 'sub-456' // optional
}, (result) => {
console.log('Tournament results:', result);
});

Parameters:

  • tournamentid (string): Tournament ID
  • subtournamentid (string, optional): Sub-tournament ID
  • callback (function): Response callback

Common Response Format

Most methods return a response object with this structure:

{
success: boolean;
message?: string;
data?: any; // Method-specific data
reqQuery?: {
statuscode: number;
msg?: string;
};
}
tip

Always check the success field before processing response data. Error details are available in message or reqQuery.msg.

Next Steps