Introduction
This documentation will provide you with the things you need in terms of using our API and collecting the data from your units.
Base URL: api.gsmcloud.com
Authentication Requests
To authenticate requests, include an Authorization header in the form “Basic {credentials}”. The value of {credentials} should be your username/id and your password, joined with a colon (:), and then base64-encoded.
All authenticated endpoints are marked with a requires authentication badge in the documentation below.
Example
const url = new URL(
"api.gsmcloud.dk/devices"
);
const headers = {
"Authorization": "Basic {YOUR_AUTH_KEY}",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Devices
List all Devices
REQUIRES AUTHENTICATION
GET / DEVICES
Headers:
Authorization:
Example: Basic {YOUR_AUTH_KEY}
Content-Type:
Example: application/json
Accept:
Example: application/json
Response:
id: Integer
Device
name: string
Given name for the device.
imei: string
IMEI number of the device.
last_package_at: string
Last time the Device was registered as online.
ports: object
name - name of the port.
label - alternative name give on port creation.
direction - in/out.
value - current value of the port.
type - data type
Example:
[
{
"id": 1,
"name": "Log test",
"imei": "868333033900099",
"last_package_at": "2023-07-10T22:44:04.000000Z",
"ports": {
"Power": {
"name": "Power",
"label": null,
"direction": "input",
"value": true,
"type": "boolean"
},
"IN 1": {
"name": "IN 1",
"label": null,
"direction": "input",
"value": 300,
"type": "temperature"
},
"IN 2": {
"name": "IN 2",
"label": null,
"direction": "input",
"value": 160,
"type": "analog"
},
"IN 3": {
"name": "IN 3",
"label": null,
"direction": "input",
"value": true,
"type": "boolean"
},
"Signal": {
"name": "Signal",
"label": null,
"direction": "input",
"value": 15,
"type": "integer"
},
"Relay": {
"name": "Relay",
"label": null,
"direction": "output",
"value": null,
"type": "boolean"
},
"Interval": {
"name": "Interval",
"label": null,
"direction": "output",
"value": null,
"type": "integer"
},
"status": {
"name": "status",
"label": null,
"direction": "input",
"value": true,
"type": "boolean"
}
}
}
]
Update a device
List all Devices
REQUIRES AUTHENTICATION
PATCH / DEVICES
Headers:
Authorization:
Example: Basic {YOUR_AUTH_KEY}
Content-Type:
Example: application/json
Accept:
Example: application/json
Response:
URL parameters:
The ID of the device
Body parameters:
name: Name (optional)
Name of the device.
Request Example:
const url = new URL(
"api.gsmcloud.dk/devices/7"
);
const headers = {
"Authorization": "Basic {YOUR_AUTH_KEY}",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"name": "ex"
};
fetch(url, {
method: "PATCH",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Response Codes
200
Success response
401
Not Auhorized
422
Validation error