Skip to main content
Version: 3.x

Taro.getWeRunData(option)

Gets the user's WeRun step counts for the past 30 days. You need to call the Taro.login API before calling this API. The step counts will update when the user opens the Mini Program.

Reference

Type

(option?: Option) => Promise<SuccessCallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

SuccessCallback

(result: SuccessCallbackResult) => void
PropertyType
resultSuccessCallbackResult

SuccessCallbackResult

PropertyTypeDescription
cloudIDstringThe Cloud ID corresponding to sensitive data. It is returned only in Mini Programs for which Cloud Base is enabled. The open data can be directly obtained via cloud call. See details.
encryptedDatastringThe complete encrypted user data, including sensitive data. For details, see Decryption Algorithm for Encrypted Data. See below for the composition of the decrypted data.
ivstringThe initial vector of the encryption algorithm. For details, see Decryption Algorithm for Encrypted Data.
errMsgstringCall result

Sample Code

Taro.getWeRunData({
success: function (res) {
// Decrypt the encryptedData in the developer's server to get open data.
const encryptedData = res.encryptedData
// Or directly get the open data via cloud call based on cloudID.
const cloudID = res.cloudID
}
})

Open Data of JSON Structure There are two ways to get sensitive data. One is to use the Decryption Algorithm for Encrypted Data. The acquired open data has the following json structure:

{
"stepInfoList": [
{
"timestamp": 1445866601,
"step": 100
},
{
"timestamp": 1445876601,
"step": 120
}
]
}

stepInfoList is composed as follows:

PropertyTypeDescription
timestampnumberTimestamp, which is the data time
stepnumberWeRun step counts

API Support

APIWeChat Mini-ProgramH5React Native
Taro.getWeRunData✔️