Manage Data Through HTTP

Figure 1.
Send Data Through HTTP
To send Data through HTTP you need a valid client-id and secret-id. To authenticate the request, you must use the client-id Oauth flow described in the Auth API Reference. Things can send Data using the client-id and secret-id that they received when they were created. In case one Thing wants to send information from another Thing, it needs to use the token from the Thing that has the Data.
The URL to POST will be api.swx.altairone.com/data
To send Data through HTTP you need to send a POST request. The Source from the Data does not need to be specified as it is automatically identified by the client-id. A POST request example:
POST api.swx.altairone.com
{
"status":{
"connected": "True",
"warnings": "False"
}
}
201 Successful response
{
"at": "2020-06-02T07:35:33Z",
"id": "21312",
"source": "thing-id"
}
Read Data Through HTTP
To read Data from a Thing in the platform you must use a GET request.
- You can get Data from a specific Thing using a GET request with the Thing
ULID.
GET https://api.swx.altairone.com/spaces/space-name/data/?source[]=ulid
GET https://api.swx.altairone.com/spaces/space-name/thing/ulid/data/
Response:{ "category": [ { "at": "2020-06-02T07:35:33Z", "id": 239086, "content": { "status":{ "connected": "True", "warnings": "False" } }, "content-type": "application/json", "source_id": 762 }, { "at": "2020-06-02T07:35:25Z", "id": 239085, "content": { "status":{ "connected": "True", "warnings": "False" } }, "content-type": "application/json", "source_id": 762 }, { "at": "2020-06-02T07:34:55Z", "id": 239084, "content": { "status":{ "connected": "True", "warnings": "False" } }, "content-type": "application/json", "source_id": 762 } ] }
- You can get specific
Data using a GET request with the Data ULID.
GET http:api.swx.altairone.com/data/123
{ “at”: “2020-06-02T07:34:55Z”, “id”: 239084, “content”: { “status”:{ “connected”: “True”, “warnings”: “False” } }, “content-type”: “application/json”, “source_id”: 762 }
- You can get a list of Data with pagination
specifying the number of items you want, and which is the first one. The
maximum number of items returned is 1000 (default).
GET http:api.swx.altairone.com/data
- You can get Data from a certain date range by indicating a reference date and the amount of Data to be returned or indicating a date range.
- You can get Data of a certain format such as text/plain or application/JSON.
Using the API Inspector
The API Inspector is an easy to use tool that enables new users to get familiar with and interact with the SmartWorks IoT API structure. Requests can be made through the API Inspector without having to worry about authentication details, as this information is automatically populated.

Figure 2.
The left panel is used for making and configuring requests, and the right panel will display the responses.
- Query Parameters Tab
- Specify the parameter key and value, and they will be URL encoded when you submit the form. See the API page to see which parameters are supported for each endpoint.
- Header Tab
- Use to define your request headers.
- Auth Tab
- Enables you to authenticate with something other than your Studio session. Here you can send requests or authentication from an application or device.
- Body Tab
- Use to make a request using a payload. Options include a JSON request, text request, or form URL encoded. For example, you can create a new Thing here, rather than using the dialog-based user interface.
Use the drop-down menu to define your REQUEST. The URL is automatically populated with your current space, which helps you select the correct end points. Edit the URL to define what you want to request. Use the Query tab to set some parameters around your request (such as limit the results to show only 2 items).
You can also revoke the tokens to close any unused sessions, which will clear the session and remove the limit. Click
to see how many active sessions are open.