Documentation

DataApi

Import

Import

  • const { DataApi } = require("@unity-services/cloud-save-1.2");

Constructors

Constructor

  • Parameters

    • Optional configuration: Configuration
    • basePath: string = ...
    • axios: AxiosInstance = ...

    Returns DataApi

Methods

Delete Item

  • deleteItem(key: string, projectId: string, playerId: string, writeLock?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<void>>
  • Deletes a data item by the specified key.

    summary

    Delete Item

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • key: string

      Item key.

    • projectId: string

      ID of the project.

    • playerId: string

      The player ID supplied by the Authorization service.

    • Optional writeLock: string
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<void>>

Delete Items

  • deleteItems(projectId: string, playerId: string, options?: AxiosRequestConfig): Promise<AxiosResponse<void>>
  • Deletes all data associated with a given player.

    summary

    Delete Items

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • projectId: string

      ID of the project.

    • playerId: string

      The player ID supplied by the Authorization service.

    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<void>>

Get Items

  • getItems(projectId: string, playerId: string, keys?: string[], after?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<GetItemsResponse>>
  • Retrieves save data values for all keys specified, ordered alphabetically in pages of 20. If no keys are supplied then returns all keys, ordered alphabetically in pages of 20.

    summary

    Get Items

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • projectId: string

      ID of the project.

    • playerId: string

      The player ID supplied by the Authorization service.

    • Optional keys: string[]
    • Optional after: string
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<GetItemsResponse>>

Get Keys

  • getKeys(projectId: string, playerId: string, after?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<GetKeysResponse>>
  • Gets a paged list of keys for the given player, ordered alphabetically in pages of 100.

    summary

    Get Keys

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • projectId: string

      ID of the project.

    • playerId: string

      The player ID supplied by the Authorization service.

    • Optional after: string
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<GetKeysResponse>>

Set Item

  • setItem(projectId: string, playerId: string, setItemBody?: SetItemBody, options?: AxiosRequestConfig): Promise<AxiosResponse<SetItemResponse>>
  • Set a data item with a given key and value for the specified player. The value is limited to a maximum size of 16KB. The entire save state for a player is limited to 200 keys. Attempting to set a new key beyond this limit will result in an error.

    summary

    Set Item

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • projectId: string

      ID of the project.

    • playerId: string

      The player ID supplied by the Authorization service.

    • Optional setItemBody: SetItemBody
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<SetItemResponse>>

Set Item Batch

  • Set up to 20 data items with key, value and optional writeLock. The values are each limited to a maximum size of 16KB. The entire save state for a player is limited to 200 keys. Attempting to set a new key beyond this limit will result in an error. The batch set operation is considered atomic and if any of the set key operation fails, the entire operation is failed. Error responses should identify the affected key operations that failed.

    summary

    Set Item Batch

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • projectId: string

      ID of the project.

    • playerId: string

      The player ID supplied by the Authorization service.

    • Optional setItemBatchBody: SetItemBatchBody
    • Optional options: AxiosRequestConfig

    Returns Promise<AxiosResponse<SetItemBatchResponse>>