GSMCloud API Documentation
Introduction
The GSMCloud API allows developers to interact with their GSMCloud devices programmatically.
- Retrieve device information
- Read input sensor values
- Control output ports such as
Relay,LED,Buzzer, andInterval - Update device names and port labels
Note: Input ports are read-only. Only output ports can be updated via the API.
Authentication
Base URL
https://api.gsmcloud.com
Format
Authorization: Basic BASE64("username:password")
Example: Example
const BASE_URL = "https://api.gsmcloud.com";
const token = Buffer.from(`${USER}:${PASS}`).toString("base64");
const baseHeaders = {
"Authorization": `Basic ${token}`,
"Accept": "application/json"
};
Device model
Devices are retrieved through:
GET /devices
The following is not supported by the API:
GET /devices/{id}
Example Device Object
You must select the correct device from the /devices response.
{
"id": 0000,
"name": "GT1000 PRO : V2",
"imei": null,
"last_package_at": "...",
"ports": {
"Power": { ... },
"Signal": { ... },
"LED": { ... },
"Relay": { ... }
}
}
Port Model
{
"name": "Relay",
"label": null,
"direction": "output",
"value": null,
"type": "boolean"
}
| Field | Type | Description |
|---|---|---|
| Name | String | Internal port name |
| Label | String | Optional description/name |
| Direction | String | Input or Output |
| Value | any | Current Port value |
| Type | String | Boolean, Integer, temperature |
Output Ports (GT1000 PRO : V2)
| Port | Type | Description |
|---|---|---|
| Relay | boolean | Relay on/off |
| LED | boolean | Status LED |
| Buzzer | boolean | Buzzer output |
| Buzzer FX | integer | Tone pattern |
| Interval | integer | Update interval |
| Relay Pulse | integer | Pulse duration |
Endpoints
GET /devices
Returns all devices with ports.
async function listDevices() {
const res = await fetch(`${BASE_URL}/devices`, {
headers: baseHeaders
});
return res.json();
}
PATCH /devices/{id}
Used to update output values, labels, or device name.
{
"ports": {
"Relay": true,
"LED": true
}
}
JavaScript Example
Examples for interacting with device outputs.
const BASE_URL = "https://api.gsmcloud.com";
const token = Buffer.from(`${USER}:${PASS}`).toString("base64");
const baseHeaders = {
"Authorization": `Basic ${token}`,
"Accept": "application/json"
};
async function listDevices() {
const res = await fetch(`${BASE_URL}/devices`, {
headers: baseHeaders
});
return res.json();
}
Update Multiple Outputs
Recommended method to update one or more output ports.
Toggle a Port
Reads current value and flips it.
async function updateOutputs(deviceId, ports) {
await fetch(`${BASE_URL}/devices/${deviceId}`, {
method: "PATCH",
headers: {
...baseHeaders,
"Content-Type": "application/json"
},
body: JSON.stringify({ ports })
});
}
// Example:
updateOutputs(0000, { Relay: true, LED: true });
async function togglePort(deviceId, portName) {
const devices = await listDevices();
const dev = devices.find(d => d.id === deviceId);
const current = dev.ports[portName].value;
const next = !current;
await updateOutputs(deviceId, { [portName]: next });
}
Update Multiple Outputs
async function printPorts(deviceId) {
const devices = await listDevices();
const dev = devices.find(d => d.id === deviceId);
for (const [name, port] of Object.entries(dev.ports)) {
console.log(name, port.direction, port.type, port.value);
}
}
Error Handling & Status Code
| Code | Description |
|---|---|
| 200 | OK |
| 204 | Update Succeeded(no body) |
| 401 | Authentication failed |
| 422 | Validation error |
Most PATCH operations return 204 No Content to indicate success.
Notes / FAQ
- Input ports cannot be modified.
- Output values depend on type (boolean/integer).
- Port names are case-sensitive.
/devices/{id}GET is not supported.- All device lookups must use
GET /devices.
End of Documentation