title: Taro.getWeRunData(option)

sidebar_label: getWeRunData

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

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

Parameters

Option

Property Type Required Description
complete (res: any) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: any) => void No The callback function for a failed API call
success (res: Result) => void No The callback function for a successful API call

SuccessCallback

  1. (result: SuccessCallbackResult) => void
Property Type
result SuccessCallbackResult

SuccessCallbackResult

Property Type Description
cloudID string The 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.
encryptedData string The complete encrypted user data, including sensitive data. For details, see Decryption Algorithm for Encrypted Data. See below for the composition of the decrypted data.
iv string The initial vector of the encryption algorithm. For details, see Decryption Algorithm for Encrypted Data.
errMsg string Call result

Sample Code

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

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:

  1. {
  2. "stepInfoList": [
  3. {
  4. "timestamp": 1445866601,
  5. "step": 100
  6. },
  7. {
  8. "timestamp": 1445876601,
  9. "step": 120
  10. }
  11. ]
  12. }

stepInfoList is composed as follows:

Property Type Description
timestamp number Timestamp, which is the data time
step number WeRun step counts

API Support

API WeChat Mini-Program H5 React Native
Taro.getWeRunData ✔️