Skip to content

Studio Script Reference: PlayFab actions

These actions interact with Microsoft Azure PlayFab, a backend gaming platform. They are available when a PlayFab data source is configured in your project.

context.actions.playFabGetAdPlacements()

Fetches available ad placements from PlayFab. Optionally filter by placement ID.

Example:

js
context.actions.playFabGetAdPlacements({
  placementId: 'my-placement-id' // optional
});

context.actions.playFabGetRequest()

Sends a custom GET request to PlayFab.

Example:

js
context.actions.playFabGetRequest({
  eventName: 'GetCharacterData',
  body: { characterId: 'abc123' }
});

context.actions.playFabLogin()

Logs the current user into PlayFab.

Example:

js
context.actions.playFabLogin();

context.actions.playFabLogout()

Logs the current user out of PlayFab.

Example:

js
context.actions.playFabLogout();

context.actions.playFabPostRequest()

Sends a custom POST request to PlayFab.

Example:

js
context.actions.playFabPostRequest({
  eventName: 'UpdateUserData',
  body: { key: 'score', value: '42' }
});

context.actions.playFabReportAdActivity()

Reports an ad lifecycle event to PlayFab for a given placement.

activity must be one of: 'Opened', 'Closed', 'Start', 'End'.

Example:

js
context.actions.playFabReportAdActivity({
  placementId: 'my-placement-id',
  activity: 'Start'
});

context.actions.playFabRewardAdActivity()

Reports a completed ad reward event to PlayFab.

Example:

js
context.actions.playFabRewardAdActivity({
  placementId: 'my-placement-id'
});

context.actions.playFabSkipAdPlacement()

Reports that an ad placement was skipped.

Example:

js
context.actions.playFabSkipAdPlacement({
  placementId: 'my-placement-id',
  currencyCode: 'USD'
});

context.actions.playFabWritePlayerEvent()

Writes a player telemetry event to PlayFab.

Example:

js
context.actions.playFabWritePlayerEvent({
  eventName: 'player_voted',
  body: { optionIndex: 2 }
});

context.actions.playFabWriteTitleEvent()

Writes a title-level telemetry event to PlayFab.

Example:

js
context.actions.playFabWriteTitleEvent({
  eventName: 'round_started',
  body: { roundId: 'round-1' }
});

context.actions.playFabAnswerPrediction()

Submits an answer to a PlayFab prediction.

Example:

js
context.actions.playFabAnswerPrediction({
  prediction: { predictionId: 'abc123' },
  answers: ['OptionA'],
  timeToAnswer: 3500 // optional, ms
});

context.actions.playfabClaimPredictionRewards()

Claims the rewards for a completed PlayFab prediction.

Example:

js
context.actions.playfabClaimPredictionRewards({
  instanceId: 'abc123' // optional
});