Manage and use APIs

Updated at:

This topic describes how to manage and use preset metric APIs, product data APIs, and custom service APIs.

Prerequisites

  • To manage and use preset metric APIs, ensure you have created products, devices, and a backup. For more information, see data ingress.

  • To manage and use product data APIs or custom service APIs, ensure you have created the corresponding APIs. For more information, see product data API and custom service API.

Manage APIs

  1. On the Instance Overview page of the IoT Platform console, click the ID or alias of the target Enterprise instance.

  2. In the left-side navigation pane, choose Data Service > Data API.

  3. On the Data API page, click the Preset Metric API, Product Data API, or Custom Service API tab. Find the API that you want to view and click View in the Actions column.

  4. On the API details page, select a version in the upper-right corner to view the API details for that version. The details include basic information, API monitoring, and parameters.

    • Click API O&M to view the API's usage.

    • Click API test to test the API and view request details, response examples, and invocation examples.

    The Basic Information section includes fields such as API Name, API Path, API Type, Status, Creation Time, Last Invocation, Invocations, and Timeout Error Condition. The API Monitoring line chart displays four metrics: Max. Latency, Avg. Latency, Calls, and Records. The Parameters section is divided into request parameters and response parameters, with columns such as Name, Type, and Required.

Use APIs

Use the API details to integrate and call the API from your server. This lets you retrieve data and utilize your data assets.

Important

The maximum number of requests per second (QPS) for calling Data Service APIs from a single Alibaba Cloud account is 100.

  • Call ListAnalyticsData to retrieve data for a specific API based on your business requirements.

  • If you use an Alibaba Cloud SDK, refer to the following examples for your programming language:

  • If you do not use an Alibaba Cloud SDK, note the following common parameters.

    Parameter

    Type

    Required

    Example

    Description

    apiPath

    String

    Yes

    pk/temperatureMax

    The API path.

    iotInstanceId

    String

    Yes

    iot-cn-npk1u******

    The instance ID. For more information, see FAQ about IoT Platform instances.

    pageNum

    Integer

    Required when pagination is enabled.

    10

    The page number.

    pageSize

    Integer

    Required when pagination is enabled.

    100

    The number of results to return per page. Maximum value: 100.

  • You can view the API's response parameters on the API details page. The following table describes the common response parameters.

    Parameter

    Type

    Example

    Description

    Count

    Long

    3

    The total number of records that match the query conditions.

    HasNext

    Boolean

    false

    Indicates whether a next page of results exists.

    • true: A next page of results exists.

    • false: No next page of results exists.

    PageNum

    Integer

    1

    The page number.

    PageSize

    Integer

    100

    The number of results returned on the current page.

    ResultJson

    String

    [{\"testCode\":\"TBB186\",\"testLevel\":5,\"testWorkYears\":3,\"testName\":\"Wang Wu\"},{\"testCode\":\"TBB1314\",\"testLevel\":2,\"testWorkYears\":4,\"testName\":\"Li Si\"},{\"testCode\":\"TBB8888\",\"testLevel\":2,\"testWorkYears\":5,\"testName\":\"Xiong Da\"}]"

    Details of the data that matches the conditions.