Install
- JavaScript
- Python
npm install @relay-x/app-sdk
pip install relayx_app_sdk
Initialize
Create a RelayApp instance with your API key and secret from console.relay-x.io.
- JavaScript
- Python
const { RelayApp } = require("@relay-x/app-sdk");
const app = new RelayApp({
api_key: "your_api_key",
secret: "your_secret",
mode: "production",
});
await app.connect();
from relayx_app_sdk import RelayApp
app = RelayApp({
"api_key": "your_api_key",
"secret": "your_secret",
"mode": "production",
})
await app.connect()
The mode parameter separates your data into isolated environments so test data never mixes with production:
"production"— Live environment for real device data"test"— Isolated sandbox for development and testing
Modules
📱
Device Management
Create, list, update, and delete devices
📡
Telemetry
Stream live data, query history, get latest readings
📨
Commands
Send one-way commands to devices
💬
RPC
Make request/reply calls to devices
⚡
Events
Subscribe to device events in real time
🔔
Alerts
Threshold, rate-change, and ephemeral alerts
📦
Groups
Logical and hierarchy-based device grouping
📬
Notifications
Webhook and email alert delivery
Quick Example
Stream live temperature data from a device and log it:
- JavaScript
- Python
const { RelayApp } = require("@relay-x/app-sdk");
const app = new RelayApp({
api_key: "your_api_key",
secret: "your_secret",
mode: "production",
});
// monitor connection
app.connection.listeners((event) => {
console.log("Connection:", event);
});
await app.connect();
// stream live telemetry
app.telemetry.stream({
device_ident: "sensor_01",
metric: ["temperature"],
callback: (data) => {
console.log(`${data.metric}: ${JSON.stringify(data.data)}`);
},
});
import asyncio
from relayx_app_sdk import RelayApp
app = RelayApp({
"api_key": "your_api_key",
"secret": "your_secret",
"mode": "production",
})
# monitor connection
app.connection.listeners(lambda event: print(f"Connection: {event}"))
await app.connect()
# stream live telemetry
async def on_telemetry(data):
print(f"{data['metric']}: {data['data']}")
await app.telemetry.stream({
"device_ident": "sensor_01",
"metric": ["temperature"],
"callback": on_telemetry,
})
Disconnect
- JavaScript
- Python
await app.disconnect();
await app.disconnect()