Skip to content

SiloScale API Reference

ทุก SiloScale API endpoints จะเริ่มด้วย:

https://api.redblu.io/v1/siloscale

รายการอุปกรณ์ SiloScale ทั้งหมด

GET /v1/siloscale/devices
Authorization: Bearer YOUR_API_KEY

Response:

{
"success": true,
"data": [
{
"device_id": "silo_001",
"name": "Silo Tank A",
"model": "SiloScale Pro 50T",
"status": "online",
"location": {
"facility": "Factory A",
"zone": "Production Floor 1"
},
"last_seen": "2024-08-05T12:00:00Z"
}
]
}

ข้อมูลอุปกรณ์เฉพาะ

GET /v1/siloscale/devices/silo_001
Authorization: Bearer YOUR_API_KEY

Response:

{
"success": true,
"data": {
"device_id": "silo_001",
"name": "Silo Tank A",
"model": "SiloScale Pro 50T",
"firmware_version": "2.1.0",
"capacity": {
"max": 50000,
"unit": "kg"
},
"sensors": [
{
"type": "level",
"sensor_id": "level_001",
"status": "active"
},
{
"type": "temperature",
"sensor_id": "temp_001",
"status": "active"
}
]
}
}

ข้อมูลเซ็นเซอร์เรียลไทม์

GET /v1/siloscale/devices/silo_001/sensors
Authorization: Bearer YOUR_API_KEY

Response:

{
"success": true,
"data": {
"level": {
"current": 85.5,
"unit": "percent",
"actual": 42750,
"actual_unit": "kg",
"timestamp": "2024-08-05T12:00:00Z"
},
"temperature": {
"current": 28.5,
"unit": "celsius",
"timestamp": "2024-08-05T12:00:00Z"
},
"humidity": {
"current": 45.2,
"unit": "percent",
"timestamp": "2024-08-05T12:00:00Z"
}
}
}

ข้อมูลประวัติเซ็นเซอร์

Parameters:

  • from: Start date (ISO 8601)
  • to: End date (ISO 8601)
  • interval: Data interval (5m, 1h, 1d)
  • sensor: Sensor type (level, temperature, humidity)
GET /v1/siloscale/devices/silo_001/sensors/history?from=2024-08-01T00:00:00Z&to=2024-08-05T23:59:59Z&interval=1h&sensor=level
Authorization: Bearer YOUR_API_KEY

Response:

{
"success": true,
"data": {
"sensor": "level",
"interval": "1h",
"points": [
{
"timestamp": "2024-08-01T00:00:00Z",
"value": 90.2
},
{
"timestamp": "2024-08-01T01:00:00Z",
"value": 89.8
}
]
}
}

เริ่มการป้อนวัตถุดิบ

POST /v1/siloscale/devices/silo_001/operations/feed
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"amount": 1000,
"unit": "kg",
"rate": 50,
"rate_unit": "kg/min"
}

Response:

{
"success": true,
"data": {
"operation_id": "op_feed_123",
"status": "started",
"estimated_duration": 20,
"duration_unit": "minutes"
}
}

POST /devices/{device_id}/operations/discharge

Section titled “POST /devices/{device_id}/operations/discharge”

เริ่มการปล่อยวัตถุดิบ

POST /v1/siloscale/devices/silo_001/operations/discharge
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"amount": 500,
"unit": "kg",
"rate": 25,
"rate_unit": "kg/min",
"target_container": "container_A"
}

GET /devices/{device_id}/operations/{operation_id}

Section titled “GET /devices/{device_id}/operations/{operation_id}”

ตรวจสอบสถานะการทำงาน

GET /v1/siloscale/devices/silo_001/operations/op_feed_123
Authorization: Bearer YOUR_API_KEY

Response:

{
"success": true,
"data": {
"operation_id": "op_feed_123",
"type": "feed",
"status": "in_progress",
"progress": 65.5,
"amount_target": 1000,
"amount_completed": 655,
"started_at": "2024-08-05T12:00:00Z",
"estimated_completion": "2024-08-05T12:20:00Z"
}
}

POST /devices/{device_id}/operations/{operation_id}/stop

Section titled “POST /devices/{device_id}/operations/{operation_id}/stop”

หยุดการทำงาน

POST /v1/siloscale/devices/silo_001/operations/op_feed_123/stop
Authorization: Bearer YOUR_API_KEY

รายการแจ้งเตือน

GET /v1/siloscale/devices/silo_001/alerts?status=active
Authorization: Bearer YOUR_API_KEY

Response:

{
"success": true,
"data": [
{
"alert_id": "alert_001",
"type": "low_level",
"severity": "warning",
"message": "Material level below threshold",
"current_value": 15.2,
"threshold": 20.0,
"created_at": "2024-08-05T11:30:00Z",
"status": "active"
}
]
}

POST /devices/{device_id}/alerts/{alert_id}/acknowledge

Section titled “POST /devices/{device_id}/alerts/{alert_id}/acknowledge”

ยืนยันการรับทราบแจ้งเตือน

POST /v1/siloscale/devices/silo_001/alerts/alert_001/acknowledge
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"acknowledged_by": "operator_001",
"note": "Scheduled maintenance in progress"
}

ดูการตั้งค่า

GET /v1/siloscale/devices/silo_001/config
Authorization: Bearer YOUR_API_KEY

Response:

{
"success": true,
"data": {
"thresholds": {
"low_level": 20.0,
"high_level": 95.0,
"critical_level": 10.0
},
"operation_limits": {
"max_feed_rate": 100,
"max_discharge_rate": 80,
"rate_unit": "kg/min"
},
"maintenance": {
"next_scheduled": "2024-08-15T08:00:00Z",
"interval_hours": 720
}
}
}

อัปเดตการตั้งค่า

PUT /v1/siloscale/devices/silo_001/config
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"thresholds": {
"low_level": 25.0,
"high_level": 90.0
}
}
Terminal window
curl -O https://api.redblu.io/postman/siloscale-collection.json
{
"api_base_url": "https://api.redblu.io/v1",
"api_key": "YOUR_API_KEY",
"device_id": "silo_001"
}
Terminal window
curl -O https://api.redblu.io/insomnia/siloscale-workspace.json
const axios = require('axios');
const client = axios.create({
baseURL: 'https://api.redblu.io/v1/siloscale',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
});
// Get current level
async function getCurrentLevel(deviceId) {
try {
const response = await client.get(`/devices/${deviceId}/sensors`);
return response.data.data.level.current;
} catch (error) {
console.error('Error:', error.response.data);
}
}
// Start feeding operation
async function startFeeding(deviceId, amount, rate) {
try {
const response = await client.post(`/devices/${deviceId}/operations/feed`, {
amount: amount,
unit: 'kg',
rate: rate,
rate_unit: 'kg/min'
});
return response.data.data.operation_id;
} catch (error) {
console.error('Error:', error.response.data);
}
}
import requests
import json
class SiloScaleAPI:
def __init__(self, api_key):
self.base_url = 'https://api.redblu.io/v1/siloscale'
self.headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
def get_current_level(self, device_id):
url = f'{self.base_url}/devices/{device_id}/sensors'
response = requests.get(url, headers=self.headers)
if response.status_code == 200:
return response.json()['data']['level']['current']
else:
raise Exception(f'API Error: {response.text}')
def start_feeding(self, device_id, amount, rate):
url = f'{self.base_url}/devices/{device_id}/operations/feed'
data = {
'amount': amount,
'unit': 'kg',
'rate': rate,
'rate_unit': 'kg/min'
}
response = requests.post(url, headers=self.headers, json=data)
if response.status_code == 200:
return response.json()['data']['operation_id']
else:
raise Exception(f'API Error: {response.text}')
# Usage
api = SiloScaleAPI('YOUR_API_KEY')
level = api.get_current_level('silo_001')
print(f'Current level: {level}%')