The Product Data API encompasses snapshot data API, raw data API, and event data API for devices associated with a product. Once a specific Product Data API is established, it enables the retrieval of raw data, snapshot data, or event data for a particular device within the product. This topic outlines the procedures for creating and editing a Product Data API.
Prerequisites
After creating a product and a device, refer to Create a Product and Create a Device for detailed instructions.
Create Product Data API
The Product Data API is limited to querying data from the past 30 days.
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.
Single click Product Data API tab, then single click Create API.
In the Create API panel, select the check box next to the target product.
Single click Apply.
The Product Data API list will be updated to include APIs for the snapshot data and raw data of the selected product.
Parameter
Snapshot Data API
Raw Data API
Event Data API
API Name
${productName} Product Snapshot Data Query
${productName} Product Raw Data Query
${productName} Product Event Data Query
API Path
/${productKey}/snapshot/data/get
/${productKey}/rawdata/get
/${productKey}/event/data/get
Where
${productName}
represents the product name, and${productKey}
is the unique identifier for the product.
Edit Product Data API
For the snapshot data query API and raw data query API, you have the option to modify the API name, input parameters, and response parameters.
Navigate to the Data API page and single click the Product Data API tab.
Locate the snapshot data query API or raw data query API for the desired product in the API list, and single click Operation followed by Edit in the corresponding column.
In the Edit API configuration wizard, update the API Basic Information and then single click Next.
Parameter
Description
API Name
Modify the API name. Accepts Chinese characters, English letters, numbers, underscores (_), and hyphens (-), up to 30 characters in length.
API Path
This field is immutable.
API Tag
Input the tag content and press Enter to create a tag. Supports Chinese characters, English letters, numbers, underscores (_), and hyphens (-), with a maximum length of 30 characters. Tags facilitate the creation of a custom ID for flexible API management.
Supports Chinese characters, English letters, digits, underscores (_), and hyphens (-), with a maximum length of 30 characters.
Utilize the tag feature to assign a custom ID to the API, enabling flexible management.
ImportantA maximum of five tags can be assigned to an API.
API Description
Provide a description for the API, detailing its functionality and other relevant information.
Return Type
The format for data returned after an API call is fixed as JSON.
On the Configure Parameters And Test page, adjust the configuration parameters and advanced settings as needed.
Category
Configuration Item
Description
Configuration Parameters
Request Parameters
Click Add Parameter and select the Attach Field to be included. Added parameters allow for setting operators, mandatory status, example values, and descriptions.
The added parameters allow for the configuration of operators, specification of their necessity, provision of example values, and inclusion of detailed descriptions.
Click the delete icon to remove a parameter.
ImportantNumeric parameter types do not support the
LIKE
operator.Response Parameters
By default, all fields returnable by the API are selected. You can determine their use for sorting, provide example values, and add descriptions.
To remove a parameter, click the delete icon. To re-add a deleted parameter, click Add Parameter, or use the Select All Parameters check box to reselect all fields as response parameters.
NoteThe Used For Sorting option allows for arranging the query results based on the field's value in ascending or descending order before returning them.
Sort Order
Choose the sequence for parameter sorting.
Select Ascending (default) to arrange parameters in ascending order.
Select Descending for descending order arrangement.
Advanced Settings
Enable Paging for Results
Decide whether to paginate the returned results.
Choose Do Not Enable to limit the viewable results to 100 entries.
Select Enable to view all results across multiple pages. Upon enabling, common parameters for pagination are automatically added:
pageNum: Specifies the page number for pagination.
pageSize: Determines the number of results per page, with a maximum of 100.
Timeout Setting
If the API call exceeds 8000 milliseconds, a timeout error will be returned. This setting is not modifiable.
Complete the configurations above, then in the Test API section, input the test values for the request parameters and click Start Test.
The sample data returned can be viewed under the Return Example tab, or click Request Details for specific request information.
Click Publish to finalize the API.
ImportantEnsure the API has been successfully tested before publishing.
The Save button must be single-clicked to display the API Details page, which will indicate the Status as Unpublished.
The API must be published to be callable for data queries.
What to do next
Utilize the Product Data API to access raw data, snapshot data, and event data for a specific device within the product.
For examples of API calls, refer to:
See Java SDK Call Example for details.
To view API usage, navigate to the API Details page. For detailed instructions on specific operations, refer to View API.