This topic outlines the management and utilization of the predefined metrics API, product data API, and custom service API.
Prerequisites
To manage and use the predefined metrics API, ensure that products and devices are created and that backups are complete.
For more information, see data access.
For the product data API or custom service API, ensure the corresponding API is created. For more information, see product data API and custom service API.
Manage an API
In the IoT Platform console, click Overview. On the Overview tab, find the instance that you want to manage and click the instance ID or the instance name.
Navigate to DataService Studio > Data APIs using the left-side navigation pane.
Navigate to the Data API page, select the Predefined Metrics API, Product Data API, or Custom Service API tab, locate the desired API, and then click View in the Operation column.
At the top right of the API Details page, choose the version number to see details of that version, including basic information, API monitoring, and parameters.
Click API Operations to review the API's usage.
Click API Test to test the API and view request details, return examples, and invocation examples.
Use an API
With the API details at hand, you can integrate and invoke the corresponding API on your server to retrieve relevant data and maximize the use of data assets.
Note that the maximum request per second (QPS) for invoking the data service API with a single Alibaba Cloud account is 100.
Invoke ListAnalyticsData to fetch data from the specified API as per business requirements.
If utilizing the SDK provided by Alibaba Cloud, refer to the following examples based on your development language:
When not using the Alibaba Cloud SDK, be mindful of the following common parameters during development:
Name
Type
Required
Example Value
Description
apiPath
String
Yes
pk/temperatureMax
The API's endpoint path.
iotInstanceId
String
Yes
iot-cn-npk1u******
The unique identifier of the IoT Platform instance the topic is associated with. For more information, see IoT Platform Instance Related Issues.
pageNum
Integer
No (Conditional)
10
The page number for paginated results.
pageSize
Integer
No (Conditional)
100
Specifies the number of records per page, up to a maximum of 100.
On the API details page, you can review the API's return parameters. Below are the common return parameters:
Name
Type
Example Value
Description
Count
Long
3
Indicates the total number of returned entries.
HasNext
Boolean
false
Specifies whether subsequent pages of data are available.
true: There is a next page.
false: There are no more pages.
PageNum
Integer
1
The current page number.
PageSize
Integer
100
The number of entries displayed per page.
ResultJson
String
[{"testCode":"TBB186","testLevel":5,"testWorkYears":3,"testName":"Jack"},{"testCode":"TBB1314","testLevel":2,"testWorkYears":4,"testName":"Tom"},{"testCode":"TBB8888","testLevel":2,"testWorkYears":5,"testName":"Eric"}]
A JSON string containing the details of the returned data.