Documentación de la API
Integra AlertG con tus dispositivos y sistemas.
Autenticación
Incluye tu clave API en el header X-API-Key en cada solicitud.
HTTP Header
X-API-Key: your_api_key_hereCreate API keys from the API Keys page in your dashboard. Each key can be scoped to ingest-only, read-only, or read-write permissions.
Integración Webhook
Envía datos de telemetría de dispositivos vía HTTP POST.
POST
/api/ingestHeaders
| Header | Requerido | Description |
|---|---|---|
| X-API-Key | Yes | Your API key |
| Content-Type | Yes | application/json |
Cuerpo de la solicitud
JSON
{
"device_id": "dev_abc123",
"payload": {
"temperature": 82.5,
"humidity": 45,
"pressure": 1013.25,
"battery": 87,
"status": "normal"
}
}Respuesta
JSON
{
"ok": true,
"device_id": "dev_abc123",
"alerts_fired": 1,
"timestamp": "2026-02-24T10:30:00Z"
}Integración MQTT
Conecta tu broker MQTT a AlertG.
Topic Format
MQTT Topic
alertgate/{user_id}/{device_id}/dataConnection Details
- Broker: mqtt.alertg.xyz
- Port: 8883 (TLS) / 1883 (plain)
- Username: Your user ID
- Password: Your API key
- Protocol: MQTT v3.1.1 / v5.0
Publish JSON payloads to the topic. The payload format is the same as the webhook request body (the payload field).
Code Examples
cURL
bash
curl -X POST https://alertg.xyz/api/ingest \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"device_id": "sensor-01",
"payload": {
"temperature": 82.5,
"humidity": 45
}
}'Python
python
import requests
response = requests.post(
"https://alertg.xyz/api/ingest",
headers={
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"device_id": "sensor-01",
"payload": {
"temperature": 82.5,
"humidity": 45,
},
},
)
print(response.json())Node.js
javascript
const response = await fetch("https://alertg.xyz/api/ingest", {
method: "POST",
headers: {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
device_id: "sensor-01",
payload: {
temperature: 82.5,
humidity: 45,
},
}),
});
const data = await response.json();
console.log(data);Arduino / ESP32
cpp
#include <WiFi.h>
#include <HTTPClient.h>
void sendData(float temperature, float humidity) {
HTTPClient http;
http.begin("https://alertg.xyz/api/ingest");
http.addHeader("Content-Type", "application/json");
http.addHeader("X-API-Key", "YOUR_API_KEY");
String payload = "{\"device_id\":\"esp32-01\",";
payload += "\"payload\":{\"temperature\":" + String(temperature);
payload += ",\"humidity\":" + String(humidity) + "}}";
int code = http.POST(payload);
if (code > 0) {
Serial.println(http.getString());
}
http.end();
}Raspberry Pi (Python)
python
import requests
import Adafruit_DHT
sensor = Adafruit_DHT.DHT22
pin = 4
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
if temperature is not None:
requests.post(
"https://alertg.xyz/api/ingest",
headers={
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"device_id": "rpi-dht22",
"payload": {
"temperature": round(temperature, 1),
"humidity": round(humidity, 1),
},
},
)Límites de tasa
Las solicitudes a la API tienen límites de tasa según tu plan.
| Plan | Ingest (req/min) | API (req/min) |
|---|---|---|
| Free | 60 | 30 |
| Hobby | 300 | 120 |
| Pro | 1,000 | 600 |
| Business | 5,000 | 3,000 |
| Enterprise | Custom | Custom |
Códigos de error
400Solicitud inválida - Carga útil o parámetros inválidos.
401No autorizado - Clave API faltante o inválida.
403Prohibido - Permisos insuficientes.
404No encontrado - El recurso no existe.
429Demasiadas solicitudes - Límite de tasa excedido.
500Error interno del servidor - Por favor inténtalo de nuevo más tarde.