API Reference

RESTful API to integrate KSP Cloud with your applications. Real-time device data, alerts, and analytics.

Base URL: https://api.ksp-cloud.com
Version: v1
Format: JSON

Quick Start

1. Get Your API Key

Generate an API key from your dashboard at Dashboard → Settings → API Keys

API_KEY: ksp_live_1a2b3c4d5e6f7g8h9i0j

2. Authenticate Requests

Include your API key in the Authorization header of every request:

curl -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     https://api.ksp-cloud.com/v1/devices

3. Make Your First Request

Fetch the list of your devices:

// Response
{
  "devices": [
    {
      "id": "deltax_001",
      "name": "Cold Storage Room 1",
      "type": "DeltaX Pro",
      "status": "online",
      "last_seen": "2025-12-07T10:30:00Z"
    }
  ],
  "total": 1
}

API Endpoints

GET/v1/devices
🔒 Auth Required

List all devices in your account

GET/v1/devices/{id}
🔒 Auth Required

Get details of a specific device

GET/v1/devices/{id}/data
🔒 Auth Required

Get latest sensor readings

GET/v1/devices/{id}/history
🔒 Auth Required

Get historical data with filtering

POST/v1/devices/{id}/alerts
🔒 Auth Required

Configure temperature alerts

PUT/v1/devices/{id}
🔒 Auth Required

Update device settings

Detailed Examples

Get Device Data

Retrieve the latest temperature and sensor readings from a specific device.

Request

GET /v1/devices/deltax_001/data
Authorization: Bearer ksp_live_1a2b3c4d5e6f7g8h9i0j

Response

{
  "device_id": "deltax_001",
  "device_name": "Cold Storage Room 1",
  "timestamp": "2025-12-07T10:30:00Z",
  "readings": {
    "temperature": 4.2,
    "humidity": 65,
    "battery": 87
  },
  "sensors": [
    {
      "id": "sensor_1",
      "location": "top_left",
      "temperature": 4.1
    },
    {
      "id": "sensor_2",
      "location": "bottom_right",
      "temperature": 4.3
    }
  ],
  "status": "ok"
}

Get Historical Data

Query historical temperature data with time range and interval filters.

Request

GET /v1/devices/deltax_001/history?start=2025-12-01&end=2025-12-07&interval=1h
Authorization: Bearer ksp_live_1a2b3c4d5e6f7g8h9i0j

Query Parameters

ParameterTypeDescription
startISO 8601Start date/time (required)
endISO 8601End date/time (required)
intervalstringData aggregation: 5m, 15m, 1h, 6h, 1d

Response

{
  "device_id": "deltax_001",
  "start": "2025-12-01T00:00:00Z",
  "end": "2025-12-07T23:59:59Z",
  "interval": "1h",
  "data": [
    {
      "timestamp": "2025-12-01T00:00:00Z",
      "avg_temperature": 4.5,
      "min_temperature": 4.0,
      "max_temperature": 5.2,
      "avg_humidity": 63
    },
    // ... more data points
  ],
  "total_points": 168
}

Configure Temperature Alerts

Set up automated alerts via WhatsApp, email, or SMS when temperature thresholds are exceeded.

Request

POST /v1/devices/deltax_001/alerts
Authorization: Bearer ksp_live_1a2b3c4d5e6f7g8h9i0j
Content-Type: application/json

{
  "name": "Cold Storage Alert",
  "enabled": true,
  "conditions": {
    "min_temperature": 2.0,
    "max_temperature": 8.0,
    "duration": 300
  },
  "notifications": {
    "whatsapp": {
      "enabled": true,
      "phone": "+919550421866"
    },
    "email": {
      "enabled": true,
      "address": "alerts@example.com"
    }
  }
}

Response

{
  "alert_id": "alert_abc123",
  "status": "created",
  "message": "Alert configured successfully"
}

Error Handling

The API uses standard HTTP status codes. All error responses include a JSON body with error details:

400Bad Request
{
  "error": "invalid_request",
  "message": "Missing required parameter: device_id"
}
401Unauthorized
{
  "error": "unauthorized",
  "message": "Invalid or expired API key"
}
429Rate Limit Exceeded
{
  "error": "rate_limit_exceeded",
  "message": "Too many requests. Limit: 100/min",
  "retry_after": 60
}

Rate Limits

PlanRequests/MinuteDaily Limit
Free6010,000
Student10050,000
Pro300500,000
EnterpriseCustomUnlimited

Need an SDK?

Use our official SDKs for faster integration in your favorite language

Browse SDKs & Libraries