REST API Document

Through this document, users will be able to send their data to the platform via API based on the information provided in the document, and the content in the document is defined according to the OpenAPI standard. Currently, the platform only supports the Post and Get methods.

The following will use the data set defined in the data format page as an example to illustrate.

API Key and Endpoint

From the red circle in the upper right corner of the above image, users can find the API key and endpoint, which are required to send data to the platform.

POST

Clicking the "downward arrow" from the purple circle on the right side of the above picture will show how to send data from the data source (in this example, FactoryA) to the platform using Post and the data format structure. You can also try sending data directly to the platform through Curl, as shown in the video below.

Use Curl

curl -X 'POST' \
  'https://api.xplatform.tranx.io/staging/FactoryA' \
  -H 'accept: */*' \
  -H 'x-api-key: XHZ56MXXXXXXXXXXXXXXXXXXXXXXXX' \
  -H 'Content-Type: application/json' \
  -d '{
  "PowerUsage": 10,
  "Temperature": 20,
  "Motor": 1200,
  "DutyManager": "John"
}'

Note:

  1. The URL in the API will be "{Endpoint}/{Data Source}".

  2. Key needs to be placed in the header, called "x-api-key".

  3. When data is sent to the platform, the system will record the current time and write it to the database. This time will also be included when exporting the data.

GET

Just like POST, clicking on the "down arrow" as shown in the following image will provide more information on usage.

After clicking on the "Try it out" button, as shown in the figure below, enter a time period and click "Execute" to obtain the data on the platform.

Use Curl

curl -X 'GET' \
  'https://api.xplatform.tranx.io/staging/FactoryA?startTime=2023-04-03%2010%3A01%3A12.534000000&endTime=2023-04-04%2023%3A59%3A12.534000000' \
  -H 'accept: application/json' \
  -H 'x-api-key: XHZ56MXXXXXXXXXXXXXXXXXXXXXXXX'

Note: The time format used here is UTC.

Error Code

Users can use the returned error codes for debugging. The following is a list of error codes:

200

Success

400

Bad request

403

Invalid API key

404

Source not found

413

Request entity too large

429

Too many requests

Last updated