Documentation

DataApi

Import

Import

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

Constructors

Constructor

  • Parameters

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

    Returns DataApi

Methods

Delete Custom Item

  • deleteCustomItem(key: string, projectId: string, customId: string, writeLock?: string, options?: AxiosRequestConfig<any>): Promise<AxiosResponse<void, any>>
  • Deletes a data item by the specified key for the specified custom ID.

    summary

    Delete Custom Item

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • key: string

      Item key.

    • projectId: string

      ID of the project.

    • customId: string

      The custom data ID specified by the user. Must be between 1 and 50 characters long and contain only alphanumeric characters, underscores, and hyphens.

    • Optional writeLock: string
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<void, any>>

Delete Custom Items

  • deleteCustomItems(projectId: string, customId: string, options?: AxiosRequestConfig<any>): Promise<AxiosResponse<void, any>>
  • Deletes all data associated with a given custom ID.

    summary

    Delete Custom Items

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • projectId: string

      ID of the project.

    • customId: string

      The custom data ID specified by the user. Must be between 1 and 50 characters long and contain only alphanumeric characters, underscores, and hyphens.

    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<void, any>>

Delete Item

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

    summary

    Delete Player 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<any>

    Returns Promise<AxiosResponse<void, any>>

Delete Items

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

    summary

    Delete Player 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<any>

    Returns Promise<AxiosResponse<void, any>>

Get Custom Items

  • getCustomItems(projectId: string, customId: string, keys?: string[], after?: string, options?: AxiosRequestConfig<any>): Promise<AxiosResponse<GetItemsResponse, any>>
  • 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 Custom Items

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • projectId: string

      ID of the project.

    • customId: string

      The custom data ID specified by the user. Must be between 1 and 50 characters long and contain only alphanumeric characters, underscores, and hyphens.

    • Optional keys: string[]
    • Optional after: string
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<GetItemsResponse, any>>

Get Custom Keys

  • getCustomKeys(projectId: string, customId: string, after?: string, options?: AxiosRequestConfig<any>): Promise<AxiosResponse<GetKeysResponse, any>>
  • Gets a paged list of keys for the given custom ID, ordered alphabetically in pages of 100.

    summary

    Get Custom Keys

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • projectId: string

      ID of the project.

    • customId: string

      The custom data ID specified by the user. Must be between 1 and 50 characters long and contain only alphanumeric characters, underscores, and hyphens.

    • Optional after: string
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<GetKeysResponse, any>>

Get Items

  • getItems(projectId: string, playerId: string, keys?: string[], after?: string, options?: AxiosRequestConfig<any>): Promise<AxiosResponse<GetItemsResponse, any>>
  • 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 Player 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<any>

    Returns Promise<AxiosResponse<GetItemsResponse, any>>

Get Keys

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

    summary

    Get Player 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<any>

    Returns Promise<AxiosResponse<GetKeysResponse, any>>

Set Custom Item

  • setCustomItem(projectId: string, customId: string, setItemBody?: SetItemBody, options?: AxiosRequestConfig<any>): Promise<AxiosResponse<SetItemResponse, any>>
  • Set a data item with a given key and value for the specified custom ID. The value is limited to a maximum size of 5 MB across all slots. The entire save state for a custom ID is limited to 2000 keys. Attempting to set a new key beyond this limit will result in an error.

    summary

    Set Custom Item

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • projectId: string

      ID of the project.

    • customId: string

      The custom data ID specified by the user. Must be between 1 and 50 characters long and contain only alphanumeric characters, underscores, and hyphens.

    • Optional setItemBody: SetItemBody
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<SetItemResponse, any>>

Set Custom Item Batch

  • setCustomItemBatch(projectId: string, customId: string, setItemBatchBody?: SetItemBatchBody, options?: AxiosRequestConfig<any>): Promise<AxiosResponse<SetItemBatchResponse, any>>
  • Set up to 20 data items with key, value and optional writeLock against the custom ID. The values are limited to a maximum size of 5 MB across all slots for the custom ID. The entire save state for a custom ID is limited to 2000 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 Custom Item Batch

    throws

    {RequiredError}

    memberof

    DataApi

    Parameters

    • projectId: string

      ID of the project.

    • customId: string

      The custom data ID specified by the user. Must be between 1 and 50 characters long and contain only alphanumeric characters, underscores, and hyphens.

    • Optional setItemBatchBody: SetItemBatchBody
    • Optional options: AxiosRequestConfig<any>

    Returns Promise<AxiosResponse<SetItemBatchResponse, any>>

Set Item

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

    summary

    Set Player 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<any>

    Returns Promise<AxiosResponse<SetItemResponse, any>>

Set Item Batch

  • Set up to 20 data items with key, value and optional writeLock for the given player. The values are limited to a maximum size of 5 MB across all slots for the player. The entire save state for a player is limited to 2000 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 Player 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<any>

    Returns Promise<AxiosResponse<SetItemBatchResponse, any>>