다음을 통해 공유


Player Data Management - Create Player Statistic Definition

Adds a new player statistic configuration to the title, optionally allowing the developer to specify a reset interval and an aggregation method.

POST https://titleId.playfabapi.com/Admin/CreatePlayerStatisticDefinition

Request Header

Name Required Type Description
X-SecretKey True

string

This API requires a title secret key, available to title admins, from PlayFab Game Manager.

Request Body

Name Required Type Description
StatisticName True

string

unique name of the statistic

AggregationMethod

StatisticAggregationMethod

the aggregation method to use in updating the statistic (defaults to last)

CustomTags

object

The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.).

VersionChangeInterval

StatisticResetIntervalOption

interval at which the values of the statistic for all players are reset (resets begin at the next interval boundary)

Responses

Name Type Description
200 OK

CreatePlayerStatisticDefinitionResult

400 Bad Request

ApiErrorWrapper

This is the outer wrapper for all responses with errors

Security

X-SecretKey

This API requires a title secret key, available to title admins, from PlayFab Game Manager.

Type: apiKey
In: header

Definitions

Name Description
ApiErrorWrapper

The basic wrapper around every failed API response

CreatePlayerStatisticDefinitionRequest

Statistics are numeric values, with each statistic in the title also generating a leaderboard. The ResetInterval enables automatically resetting leaderboards on a specified interval. Upon reset, the statistic updates to a new version with no values (effectively removing all players from the leaderboard). The previous version's statistic values are also archived for retrieval, if needed (see GetPlayerStatisticVersions). Statistics not created via a call to CreatePlayerStatisticDefinition by default have a VersionChangeInterval of Never, meaning they do not reset on a schedule, but they can be set to do so via a call to UpdatePlayerStatisticDefinition. Once a statistic has been reset (sometimes referred to as versioned or incremented), the now-previous version can still be written to for up a short, pre-defined period (currently 10 seconds), to prevent issues with levels completing around the time of the reset. Also, once reset, the historical statistics for players in the title may be retrieved using the URL specified in the version information (GetPlayerStatisticVersions). The AggregationMethod determines what action is taken when a new statistic value is submitted - always update with the new value (Last), use the highest of the old and new values (Max), use the smallest (Min), or add them together (Sum).

CreatePlayerStatisticDefinitionResult
PlayerStatisticDefinition
StatisticAggregationMethod
StatisticResetIntervalOption

ApiErrorWrapper

The basic wrapper around every failed API response

Name Type Description
code

integer

Numerical HTTP code

error

string

Playfab error code

errorCode

integer

Numerical PlayFab error code

errorDetails

object

Detailed description of individual issues with the request object

errorMessage

string

Description for the PlayFab errorCode

status

string

String HTTP code

CreatePlayerStatisticDefinitionRequest

Statistics are numeric values, with each statistic in the title also generating a leaderboard. The ResetInterval enables automatically resetting leaderboards on a specified interval. Upon reset, the statistic updates to a new version with no values (effectively removing all players from the leaderboard). The previous version's statistic values are also archived for retrieval, if needed (see GetPlayerStatisticVersions). Statistics not created via a call to CreatePlayerStatisticDefinition by default have a VersionChangeInterval of Never, meaning they do not reset on a schedule, but they can be set to do so via a call to UpdatePlayerStatisticDefinition. Once a statistic has been reset (sometimes referred to as versioned or incremented), the now-previous version can still be written to for up a short, pre-defined period (currently 10 seconds), to prevent issues with levels completing around the time of the reset. Also, once reset, the historical statistics for players in the title may be retrieved using the URL specified in the version information (GetPlayerStatisticVersions). The AggregationMethod determines what action is taken when a new statistic value is submitted - always update with the new value (Last), use the highest of the old and new values (Max), use the smallest (Min), or add them together (Sum).

Name Type Description
AggregationMethod

StatisticAggregationMethod

the aggregation method to use in updating the statistic (defaults to last)

CustomTags

object

The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.).

StatisticName

string

unique name of the statistic

VersionChangeInterval

StatisticResetIntervalOption

interval at which the values of the statistic for all players are reset (resets begin at the next interval boundary)

CreatePlayerStatisticDefinitionResult

Name Type Description
Statistic

PlayerStatisticDefinition

created statistic definition

PlayerStatisticDefinition

Name Type Description
AggregationMethod

StatisticAggregationMethod

the aggregation method to use in updating the statistic (defaults to last)

CurrentVersion

number

current active version of the statistic, incremented each time the statistic resets

StatisticName

string

unique name of the statistic

VersionChangeInterval

StatisticResetIntervalOption

interval at which the values of the statistic for all players are reset automatically

StatisticAggregationMethod

Name Type Description
Last

string

Max

string

Min

string

Sum

string

StatisticResetIntervalOption

Name Type Description
Day

string

Hour

string

Month

string

Never

string

Week

string

Error Codes

Name Code
StatisticCountLimitExceeded 1203
StatisticNameConflict 1196