Namespace: playerApi

Playbasis. playerApi

Playbasis Player API

Methods


<static> actionCount(playerId, actionName)

Returns the number of times that a player has performed the specified action.

Parameters:
Name Type Description
playerId String

player id

actionName String

name of the action to query

Returns:

Promise Object

Type
Object

<static> actionTime(playerId, actionName)

Return the last time that player has performed the specified action.

Parameters:
Name Type Description
playerId String

player id

actionName String

name of action to query

Returns:

Promise Object

Type
Object

<static> allBadges(playerId, options)

Return information about all the badges of the client as well as the amount that a player may earn.

Parameters:
Name Type Description
playerId String

player id

options Object

(optional) options as object.
It can include.
{ tags: String = specific tags to find, each tag delimited by comma i.e. foo,bar
}

Returns:

Promise Object

Type
Object

<static> allQuestsOfPlayer(playerId)

Return list of all available quests of the client as well as the status of the player if joined.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> badge(playerId, options)

Return information about all the badges that a player has earned.

Parameters:
Name Type Description
playerId String

player id

options Object

(optional) options as object.
It can include
{
tags: String = specific tags to find, each tag delimited by comma i.e. foo,bar
}

Returns:

Promise Object

Type
Object

<static> deductBadge(playerId, badge, amount, options)

Deduct a badge from a given player.

Parameters:
Name Type Description
playerId String

player id

badge String

name of badge to deduct

amount Number

amount to deduct

options Object

(optional) options as Object.
It can include
{
force: Number = 0 for not force if player has not enough badge to deduct | 1 = force to do the deduct (and player's badge becomes zero)
}

Returns:

Promise Object

Type
Object

<static> deductReward(playerId, reward, amount, options)

Deduct a reward from player

Parameters:
Name Type Description
playerId String

player id

reward String

reward name to deduct from player

amount Number

amount of reward to deduct

options Object

(optional) options as Object.
It can include
{
force: Number = 0 for not force if player has not enough reward to deduct | 1 = force to do the deduct (and player's reward becomes zero)
}.

Returns:

Promise Object

Type
Object

<static> delete(playerId)

Permanently delete player from Playbasis database.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> favoriteGoods(playerId, goodsId, status)

Set specific goods in player's inventory as favorite

Parameters:
Name Type Description
playerId String

player id

goodsId String

goods id to set favorite status

status Boolean

status to set. It can be either true or false

Returns:

Promise object

Type
Object

<static> findPlayerBySession(sessionId)

Find a player by given session id.

Parameters:
Name Type Description
sessionId String

session id

Returns:

Promise Object

Type
Object

<static> giveGift(sentPlayerId, receivedPlayerId, giftId, type, amount)

Give gift item from player to player.

Parameters:
Name Type Description
sentPlayerId String

player id that send the gift

receivedPlayerId String

player id that received the gift

giftId String

gift id can be badge id, goods id , custom point id

type String

type of gift, the value can be "badge" | "custom_point" | "goods"

amount Number

amount of gift to be sent to received player

Returns:

Promise Object

Type
Object

<static> goods(playerId, options)

Returns information about all the goods list that a player has redeem.

Parameters:
Name Type Description
playerId String

player id

options Object

(optional) options as Object.
It can include
{
tags: String = tag to query separated by comma,
status: String = "all" | "active" | "expired" | "used". Default is "active".
}.


<static> goodsCount(playerId, options)

Returns information about number of goods that player has

Parameters:
Name Type Description
playerId String

player id

options Object

(optional) options as Object.
It can include
{
tags: String = goods tag to query separated by comma,
status: String = "all" | "active" | "expired" | "used". Default is "active".
}.

Returns:

Promise object

Type
Object

<static> lastAction(playerId)

Return the time and action that a player last performed.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> level(level)

Return detail of level

Parameters:
Name Type Description
level Number

numbe of level

Returns:

Promise Object

Type
Object

<static> levels()

Return all detail of level.

Returns:

Promise Object

Type
Object

<static> listActivePlayerSessions(playerId)

List active sessions of a player in Playbasis system.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> listCustomFieldsOfPlayer(playerId)

Get custom fields information about a player.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> listPlayer(playerIdArray)

Get basic information of players

Parameters:
Name Type Description
playerIdArray String

array of player id String

Returns:

Promise Object

Type
Object

<static> login(playerId)

Tell Playbasis system that a player has logged in.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> logout(playerId)

Tell Playbasis system that a player has logged out.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> performOTPVerification(playerId, OTPcode)

Perform OTP verification from code that has sent to player SMS.

Parameters:
Name Type Description
playerId Stirng

player id

OTPcode String

OTP code as sent to player

Returns:

Promise Object

Type
Object

<static> playerDetailedInfo(playerId)

Get detailed public and private information about player, including points and badges.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> playerDetailedPublicInfo(playerId)

Get detailed public information about player, including points and badges.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> playerInfo(playerId)

Get public and private information about a player.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> playerPublicInfo(playerId)

Get public information about player.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> playerReferralCode(playerId)

Return generated referral code of player.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> point(playerId, pointName)

Returns how much of specified the point-based reward a player currently has.

Parameters:
Name Type Description
playerId String

player id

pointName String

name of point-based reward to query

Returns:

Promise Object

Type
Object

<static> pointHistory(playerId, options)

Returns history points of player

Parameters:
Name Type Description
playerId String

player id

options Object

(optional) options as Object.
It can include
{
point_name: String = "point" | "exp" | ...,
offset: Number = offset of returned records,
limit: Number = number of returned records to return,
order: String = "desc" | "asc"
}

Returns:

Promise Object

Type
Object

<static> points(playerId)

Return information about all point-based rewards that a player currently has.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> questListOfPlayer(playerId, options)

Return list of quests that player has joined.

Parameters:
Name Type Description
playerId String

player id

options Object

(optional) options as Object.
It can include
{
tags: String = tag to query separated by comma
}.


<static> questOfPlayer(playerId, questId)

Return information about the specified quest that player has joined.

Parameters:
Name Type Description
playerId String

player id

questId String

quest id that playered has joined, to get information from


<static> questRewardHistory(playerId, options)

Return quest reward history of player.

Parameters:
Name Type Description
playerId String

player id

options Object

(optional) options as Object.
It can include
{
offset: Number,
limit: Number
}

Returns:

Promise Object

Type
Object

<static> rank(rankBy, limit, options)

Return the list of players sorted by the specified point type.

Parameters:
Name Type Description
rankBy String

point-based name to rank by ("exp" | "point", etc)

limit Number

amount of items to return

options Object

(optional) options as Object. It can include
{
mode: String = "all-time" | "weekly" | "monthly"
}.

Returns:

Promise Object

Type
Object

<static> ranks(limit, options)

Return list of players sorted by each point type.

Parameters:
Name Type Description
limit Number

limit number of players returned in the list

options Object

(optional) option as Object. It can include
{
mode: String = "all-time" | "weekly" | "monthly"
}.


<static> referral(playerId, referralCode, options)

Referral player

Parameters:
Name Type Description
playerId String

player id

referralCode String

referral code of another player for invitation system

options String

(optional) option as Object. It can include { key: String = It can be any key and value, }

Returns:

Promise Object

Type
Object

<static> register(playerId, email, options)

Register player

Parameters:
Name Type Description
playerId String

player id

email String

email to register player with

options String

(optional) option as Object.
It can include
{
image: String = url to the player profile image,
phone_number: String = phone number in format +66xxyyyzzzz,
facebook_id: String = facebook id of player,
twitter_id: String = twitter id of player,
password: String = password,
first_name: String = first name of player,
last_name: *String = last name of player,
gender: *Number = 1 for Male | 2 for Female,
birth_date: String = date of birth in the format YYYY-MM-DD (ex. 1982-09-29),
code: String = referral code of another player for invitation system,
anonymous: Number = 0 | 1,
device_id: String = device id to verify with SMS verification process,
approve_status: String = "approved" | "rejected" | "pending",
}

Returns:

Promise Object

Type
Object

<static> requestOTP(playerId)

Request one time password.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object

<static> requestOTPforSetupPhone(playerId, phoneNumber)

Request one time password for setup phone.

Parameters:
Name Type Description
playerId String

player id

phoneNumber String

phone number in format +66xxyyyzzzz

Returns:

Promise Object

Type
Object

<static> resetPlayerPassword(email)

Reset player password that store in Playbasis system.

Parameters:
Name Type Description
email String

email of player

Returns:

Promise Object

Type
Object

<static> setCustomFieldOfPlayer(playerId, key, value)

Set custom field of player

Parameters:
Name Type Description
playerId String

player id

key String

key of custom field

value String

value of custom field


<static> update(playerId, updates)

Update player information

Parameters:
Name Type Description
playerId String

player id

updates Object

update values as Object.
It can include
{
username: String = username,
email: String = email,
image: String = image url of player,
phone_number: String = phone number in format +66xxyyzzz,
exp: Number = experience point,
level: Number = level,
facebook_id: String = facebook id of player,
twitter_id: String = twitter id of player,
password: String = password of player,
first_name: String = first name of player,
last_name: String = last name of player,
gender: Number = 1 for Male | 2 for Female,
birth_date: String = birth date in format YYYY-MM-DD (ex. 1982-09-29),
device_id: String = device id to verfiy with SMS verification process,
approve_status: String = "approved" | "rejected" | "pending"
}

Returns:

Promise Object

Type
Object

<static> verifyPlayerEmail(playerId)

Verify player email that store in Playbasis system by sending verification email.

Parameters:
Name Type Description
playerId String

player id

Returns:

Promise Object

Type
Object