About EnOS API¶
EnOS provides REST APIs that cover the core business processes of the system. Based on these APIs, developers can access resources within the EnOS system to develop various applications.
API Scope of Application¶
EnOS Cloud and EnOS Edge both provide APIs that cover the core business processes of the systems. Most of the APIs are supported by both EnOS Cloud and EnOS Edge. Before developing applications based on these APIs, ensure that you checked the description of API application scope on the overview page of each API service documentation.
API Service List¶
EnOS provides the following API services:
Model Service: Search and get the details of the models in an organization.
Connection Service: Provide device connectivity and device management on EnOS, including product and device creation and management.
Asset Service: Create, manage, and update the assets in an organization.
Asset Tree Service: Create, manage, update, and search assets trees in an organization.
Alert Service: Search and manage asset alerts.
Stream Processing Service: Provide query and operation management of stream processing jobs.
TSDB Policy Service: Access to TSDB storage configuration information.
TSDB Data Service: Access to the stored asset data.
Data Federation Service: Provide data reading and data writing services for multi-source heterogeneous data storage systems.
Batch Processing Service: Provide data integration, data development, data operation, and maintenance services that are required for big data analysis.
Application Portal Service: Get information about users, assets, and applications to configure permissions on the EnOS Application Portal.
Business Process Management Service:Provide business process and task query and management service.
Notification Management Service: Provide message push management service interface and enable push message push function.
IAM Service: Manage user account lifecycles, authenticate user identities, and control the access rights to the resources in EnOS.
EnOS Edge API services: Provide APIs specific for EnOS Edge products.
API Request¶
The EnOS API request consists of the following parts:
Request URI¶
{URI-scheme}://{apigw-address}/{service-name}/{version}/{endpoint-URL}?{query-param=value}
URI-sheme
: The protocol, supporting HTTPS protocol.apigw-address
: The IP address or domain of EnOS Cloud API or EnOS Edge API, which can be retrieved by logging in to the EnOS Management Console and clicking Help > Environment Information at the top right. Refer to the address under API Gateway.service-name
: The service name, e.g.asset-service
.version
: The API version, e.g.v2.0
.endpoint-URL
: The resources and operations on resources, e.g.assets/update
.query-param
: The parameters and values for the target resource, e.g.orgId=1234
. When there are multiple query parameters, they should be connected by&
.
For example, to get the asset information in an organization, send the following API request:
GET
https://{apigw-address}/asset-service/v2.1/assets?action=get&orgId=1234&assetId=abcd
Request Header¶
Any other fields required by the REST API specifications and HTTP specifications of the Request URI are bound in the request header.
The commonly used request header is Content-Type
, which represents the data submission method. Generally, its value can be set to application/json;charset=UTF-8
; if file uploading or other form submission is performed, the value is set to Multipart/form-data;charset=UTF-8
.
Request Body¶
The request body supplements the Request URI, enabling users to provide input parameters that are more complex. For example, the request body below contains parameters that specify the timezone, description, tags, and other attributes to update an asset:
POST
https://{apigw-address}/asset-service/v2.1/assets?action=update&orgId=1234&isPatchUpdate=fasle
{
"asset": {
"modelId": "testModel",
"assetId": "123",
"timezone": "+08:00",
"description": "hahdesc",
"tags": {
"site": "Shanghai",
"producer": "ABC"
}
}
}
API Response¶
An example of the EnOS API response in JSON format with its parameters explained is shown below:
{
"code": 0,
"msg": "OK",
"requestId": "6cb7a013-7f83-4620-97c8-4695a892acdf",
"data": {
}
}
Description of the response parameters is as follows:
Name |
Data Type |
Description |
---|---|---|
code |
Integer |
The API request status code. “0” means that the request is successful. For other status codes, refer to the public return codes and the error codes in the API documentation. |
msg |
String |
The explanation of the status codes. “OK” indicates a successful request. If the API request fails, the specific error information will be returned. |
requestId |
String |
The ID for each request. It is a unique identifier for an API request. |
data |
Array or Object |
The set of API response results. Data types include: basic data types, complex types, or arrays. |
Description of Public Parameters¶
The public parameters for each API service are described below. For how to get and use other common parameters, see API FAQs
Pagination Request Struct¶
The Pagination parameter is used for random pagination. The default pagination value is 10.
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
pageNo |
Mandatory |
Integer |
The request pages, starting from 1. (It starts from 0 for Application Portal service.) |
pageSize |
Mandatory |
Integer |
The number of records in each page, which must be greater than 0. |
sorters |
Optional |
Sorter struct |
The pagination sorting method. (Not supported in Application Portal service.) |
Sorter struct
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
field |
Mandatory |
String |
The pagination field name. |
order |
Optional |
String |
|
Pagination parameter sample
{
"pagination": {
"pageNo": 2,
"pageSize": 100,
"sorters": [{
"field": "assetId",
"order": "ASC"
}]
}
}
Public Request Parameters (Connection Service, etc.)¶
The public request parameters for the connection service, model service, asset service, event service, and asset tree service APIs are as follows:
Projection Parameter¶
The projection
parameter is used to crop the returned data result set. Its data type is String Array. Each of the string represents a result field that needs to be returned in the returned result. Any fields that are not specified in the projection would not be returned in the result set. When specifying a field, you can use:
Symbol |
Description |
---|---|
|
Stands for each object in an array |
|
Stands for any field value |
|
Stands for a sub-field |
When the projection parameter is not provided, the data result set is not cropped.
Projection parameter sample
{
"projection": [
"assetPaths”, “assets.*.assetId”
]
}
Public Response Parameters (Connection Service, etc.)¶
The public response parameters for the connection service, model service, asset service, event service, and asset tree service APIs are:
Name |
Data Type |
Description |
---|---|---|
pagination |
Pagination response struct |
The pagination information for the current returned results. |
Public Response Codes (Connection Service, etc.)¶
Note
Only the common response codes are listed here. Refer to the specific API documentation for the specific response codes of each interface.
The public response codes for the connection service, model service, asset service, event service, and asset tree service APIs are:
Code |
Description |
---|---|
99400 |
The request parameter is invalid. Check the request parameters. |
99403 |
Missing permissions. Make sure you have the permission to access the API and requested resources. |
99404 |
The specified object does not exist. For example, when getting, updating, or deleting a device, the specified |
99500 |
Internal server error. Contact EnOS support. |
Sample:
99400 error sample: missing parameter
{
"code": 99400,
"msg": "Invalid Argument action:action is missing",
"requestId": "4d4bfd4d-b5c5-4b9c-b452-833516153b49",
"data": null
}
99400 error sample: Invalid parameter
{
"code": 99400,
"msg": "Invalid Argument orgId: orgId does not exist",
"requestId": "4d4bfd4d-b5c5-4b9c-b452-833516153b49",
"data": null
}
99403 error sample: missing permissions
{
"code": 99403,
"msg": “Denied resource: orgId o1558xxxxxxxxxx",
"requestId": "4d4bfd4d-b5c5-4b9c-b452-833516153b49",
"data": null
}
99500 error sample: internal server error
{
"code": 99500,
"msg": " Internal Server Error",
"requestId": "4d4bfd4d-b5c5-4b9c-b452-833516153b49",
"data": null
}
Public Response Codes (TSDB Data Service)¶
Note
Only the common response codes are listed here. Refer to the specific API documentation for the specific response codes of each interface.
The public response codes for the TSDB data service APIs are:
Code |
Message |
Description |
---|---|---|
0 |
OK |
API request is successful. |
80400 |
Invalid param error |
One or more parameters are invalid. For details, see the error message. |
80401 |
Asset unauthorized |
The SA does not have access permission to assets. Check the authorization to the application SA. |
80500 |
Internal server error |
Internal server error. |