API Reference
The TwinEdge API provides programmatic access to all platform features. Use it to integrate TwinEdge with your existing systems, automate workflows, or build custom applications.
Base URL
All API requests should be made to:
https://api.twinedgeai.com/v1
Authentication
TwinEdge uses API keys for authentication. Include your API key in the Authorization header:
curl -X GET "https://api.twinedgeai.com/v1/devices" \
-H "Authorization: Bearer YOUR_API_KEY"
To create an API key:
- Go to Settings → API Keys
- Click Create New Key
- Set permissions and expiration
- Copy and securely store your key
Never expose your API key in client-side code. Always use server-side requests or environment variables.
Rate Limits
API requests are rate limited based on your subscription tier:
| Tier | Requests/Minute | Requests/Day |
|---|---|---|
| Trial | 60 | 1,000 |
| Starter | 300 | 10,000 |
| Professional | 1,000 | 100,000 |
| Enterprise | Custom | Custom |
Rate limit headers are included in all responses:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1704067200
Response Format
All responses are JSON with a consistent structure:
Success Response
{
"data": { ... },
"meta": {
"page": 1,
"per_page": 20,
"total": 100
}
}
Error Response
{
"error": {
"code": "RESOURCE_NOT_FOUND",
"message": "Device with ID 'xyz' not found",
"details": { ... }
}
}
Common Error Codes
| HTTP Status | Code | Description |
|---|---|---|
| 400 | VALIDATION_ERROR | Invalid request parameters |
| 401 | UNAUTHORIZED | Missing or invalid API key |
| 403 | FORBIDDEN | Insufficient permissions |
| 404 | NOT_FOUND | Resource not found |
| 429 | RATE_LIMITED | Too many requests |
| 500 | INTERNAL_ERROR | Server error |
API Endpoints
Telemetry
| Method | Endpoint | Description |
|---|---|---|
| GET | /telemetry | Query telemetry data |
| POST | /telemetry/ingest | Ingest telemetry data |
| GET | /telemetry/latest | Get latest values |
Devices
| Method | Endpoint | Description |
|---|---|---|
| GET | /devices | List all devices |
| POST | /devices | Create a device |
| GET | /devices/{id} | Get device details |
| PUT | /devices/{id} | Update a device |
| DELETE | /devices/{id} | Delete a device |
Dashboards
| Method | Endpoint | Description |
|---|---|---|
| GET | /dashboards | List dashboards |
| POST | /dashboards | Create dashboard |
| GET | /dashboards/{id} | Get dashboard |
| PUT | /dashboards/{id} | Update dashboard |
Alerts
| Method | Endpoint | Description |
|---|---|---|
| GET | /alerts | List alert rules |
| POST | /alerts | Create alert rule |
| GET | /alerts/events | Get triggered alerts |
ML Models
| Method | Endpoint | Description |
|---|---|---|
| GET | /ml/models | List models |
| POST | /ml/training | Start training job |
| GET | /ml/predictions | Get predictions |
SDKs and Libraries
Official client libraries are available for:
- Python:
pip install twinedge - JavaScript/TypeScript:
npm install @twinedge/sdk
Webhooks
TwinEdge can send webhooks for events like:
- Alert triggered
- Device offline
- Training job completed
Configure webhooks in Settings → Integrations → Webhooks.
OpenAPI Specification
The OpenAPI 3.0 specification is available from the API:
- JSON:
https://api.twinedgeai.com/openapi.json - YAML:
https://api.twinedgeai.com/openapi.yaml
Import into Postman, Insomnia, or your favorite API client.