TikTok for Developers

Developer Docs

Last updated October 1, 2026

Open APIs

Handle user authentication and authorization through silent login and scope-based permission requests, and provide access to the open data context for reading user cloud storage and relational data.

TTMinis.game.login(opts)

Initiates a silent login for the mini game.

Parameters

Field

Type

Description

Required

success

function

The callback function called when the API call succeeds

No

fail

function

The callback function called when the API call fails

No

complete

function

The callback function called when the API call ends, regardless of success or failure

No

Success callback parameters

Field

Type

Description

code

string

The login authorization code. Send this code to the backend server in exchange for open_id, access_token, and other credentials.

Example

TTMinis.game.login({
  success: (result) => {
    // The user has logged in and authorized the application
    // Send the code to the backend in exchange for open_id, access_token, etc.
    let code = result.code;
  },
  fail: (error) => {
    // Other errors or deauthorization; code is null
  },
  complete: () => {
    // Triggered for both success and failure
  }
});

TTMinis.game.authorize(opts)

Initiates the authorization flow for the mini game.

Parameters

Field

Type

Description

Required

scope

string

The scope of the permission to request. See the scope list for details.

Yes

success

function

The callback function called when the API call succeeds

No

fail

function

The callback function called when the API call fails

No

complete

function

The callback function called when the API call ends, regardless of success or failure

No

Success callback parameters

Field

Type

Description

code

string

The authorization code. Send this code to the backend server in exchange for open_id, access_token, and other credentials.

Example

TTMinis.game.authorize({
  scope: 'user.info.basic',
  success: (result) => {
    // The user has logged in and authorized the application
    // Send the code to the backend in exchange for open_id, access_token, etc.
    let code = result.code;
  },
  fail: (error) => {
    // Other errors or deauthorization; code is null
  },
  complete: () => {
    // Triggered for both success and failure
  }
});

TTMinis.game.getOpenDataContext()

Gets the open data context.

Returns

An OpenDataContext object for interacting with the open data domain.

Example

const openDataContext = TTMinis.game.getOpenDataContext()

OpenDataContext

The open data context object, which provides a shared canvas and messaging between the main domain and the open data domain.

Properties

Field

Type

Description

canvas

Canvas

The shared canvas between the open data domain and the main domain

OpenDataContext.postMessage(message)

Sends a message to the open data domain.

Parameters

Field

Type

Description

Required

message

object

The message to send. Values of keys in the message and nested objects can only be primitive types: number, string, boolean, null, or undefined.

Yes

Example

const openDataContext = TTMinis.game.getOpenDataContext()
openDataContext.postMessage({
  type: 'updateScore',
  score: 100
})

TTMinis.game.setUserCloudStorage(opts)

Writes user-managed cloud storage data. Supports writing multiple key-value pairs at once.

Parameters

Field

Type

Description

Required

KVDataList

list<KVData>

The list of key-value data to write

Yes

success

function

The callback function called when the API call succeeds

No

fail

function

The callback function called when the API call fails

No

complete

function

The callback function called when the API call ends, regardless of success or failure

No

KVData

Field

Type

Description

key

string

The key of the data entry

value

string

The value of the data entry

Example

TTMinis.game.setUserCloudStorage({
  KVDataList: [{
    key: 'score',
    value: '100'
  }, {
    key: 'level',
    value: '5'
  }],
  success: () => {
    console.log('Cloud storage updated')
  }
})

TTMinis.game.removeUserCloudStorage(opts)

Deletes user-managed cloud storage data for the specified keys.

Parameters

Field

Type

Description

Required

KVDataList

list<string>

The list of keys to delete

Yes

success

function

The callback function called when the API call succeeds

No

fail

function

The callback function called when the API call fails

No

complete

function

The callback function called when the API call ends, regardless of success or failure

No

Example

TTMinis.game.removeUserCloudStorage({
  KVDataList: ['score', 'level'],
  success: () => {
    console.log('Cloud storage entries removed')
  }
})
TikTok for Developers