API Documentation
Sistem Monitoring Biogas & Waste Management — Depok · Jatisari · Indramayu
How to Use This API
Complete integration guide for RMC API
Authentication
Most endpoints require authentication using a Bearer token obtained from the
/login endpoint.
Base URL
All API endpoints are relative to:
https://monitoring.xampah.com/api/
Rate Limits
60 req/min • 1,000 req/hour • 10,000 req/day
Common Headers
Required Headers for All Requests
Content-Type: application/jsonAccept: application/jsonAuthorization: Bearer {your_token}
(for protected endpoints)
Response Format
{
"success": true, // Boolean indicating request success
"message": "Success", // Human readable message (optional)
"data": {}, // Response data (object or array)
"meta": { // Pagination meta (for paginated responses)
"current_page": 1,
"per_page": 15,
"total": 100
}
}
Error Handling
| HTTP Code | Error Type | Description |
|---|---|---|
| 200 | OK | Request successful |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | Invalid parameters or validation failed |
| 401 | Unauthorized | Missing or invalid authentication token |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource not found |
| 422 | Unprocessable Entity | Validation errors |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server error |
Authentication Flow
Login Request
curl -X POST https://monitoring.xampah.com/api/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "your_password"
}'
Login Response
{
"success": true,
"token": "your_bearer_token_here",
"user": {
"id": 1,
"name": "User Name",
"email": "user@example.com"
}
}
Example Workflows
Scavenger Workflow
1
Register card:
POST /register-card-member
2
Record attendance:
POST /attendance
3
Save waste weight:
POST /scavengers/save-mlo
4
View rankings:
GET /scavengers/users
5
Get total weight:
GET /scavengers/total-weight
Biogas Monitoring
1
Push Depok data:
POST /biogas
2
Push Jatisari data:
POST /biogas/jatisari/push
3
Push Indramayu data:
POST /biogas/indramayu/push
4
Get latest:
GET /biogas-data/latest
5
View stats:
GET /biogas-data/stats
Vehicle Weight
1
Record entry:
POST /weightDataIn
2
Record exit:
POST /weightDataOut
3
Get history:
GET /weight/data
4
Get latest:
GET /weight/latest
Code Examples
PHP - cURL
<?php
// PHP cURL Example - Save MLO Weight
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://monitoring.xampah.com/api/scavengers/save-mlo',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-KEY: sk_xxxxxxxxxxxxxxxxxxxxxxxxx',
],
CURLOPT_POSTFIELDS => json_encode([
'user_id' => 1,
'weight' => 5.5,
]),
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo curl_error($ch);
}
curl_close($ch);
echo $response;
JavaScript - Fetch API
// JavaScript Fetch Example
async function saveMlo(userId, weight) {
const response = await fetch(
'https://monitoring.xampah.com/api/scavengers/save-mlo',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'sk_xxxxxxxxxxxxxxxxxxxxxxxxx',
},
body: JSON.stringify({ user_id: userId, weight }),
}
);
const data = await response.json();
console.log(data);
}
saveMlo(1, 5.5);
Python - Requests
# Python Requests Example
import requests
url = "https://monitoring.xampah.com/api/scavengers/save-mlo"
headers = {
"Content-Type": "application/json",
"X-API-KEY": "sk_xxxxxxxxxxxxxxxxxxxxxxxxx",
}
data = {"user_id": 1, "weight": 5.5}
response = requests.post(url, json=data, headers=headers, timeout=10)
print("Status:", response.status_code)
print(response.json())
Depok API Endpoints
Biogas monitoring, weight management, temperature, and scavenger waste tracking
Biogas Monitoring
GET
/biogas-data/latest
Most recent biogas record
json
{
"success": true,
"data": {
"id": 1,
"ph_1": 7.2,
"ph_2": 7.1,
"gas_value_1": 85.5,
"gas_value_2": 42.3,
"pressureGas_1": 2.1,
"temperatureGas_1": 35.2,
"created_at": "2024-01-15 10:30:00"
}
}
GET
/biogas-data/paginated
Paginated biogas data list
| Parameter | Type | Required | Description |
|---|---|---|---|
| page | integer | optional (default: 1) | Page number |
| per_page | integer | optional (default: 15) | Items per page (max 100) |
GET
/biogas-data/stats
Statistical summary
Scavengers Waste Management
GET
/scavengers/users
Get all scavenger users with rankings
| Parameter | Type | Required | Description |
|---|---|---|---|
| date | date | optional | Filter by date (Y-m-d) - default today |
GET
/scavengers/users/{user_id}
Get detailed information for specific scavenger
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| date | date | optional | Filter by date (Y-m-d) |
GET
/scavengers/total-weight
Get total weight summary by waste category
| Parameter | Type | Required | Description |
|---|---|---|---|
| date | date | optional | Date (Y-m-d) - default today |
| user_id | integer | optional | Filter by specific user |
GET
/scavengers/total-weight-range
Get total weight for date range
| Parameter | Type | Required | Description |
|---|---|---|---|
| start_date | date | required | Start date (Y-m-d) |
| end_date | date | required | End date (Y-m-d) |
| user_id | integer | optional | Filter by specific user |
POST
/scavengers/save-mlo
Save MLO (Minyak Limbah Organik) weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| weight | float | required | Weight in kg |
json
{
"user_id": 1,
"weight": 5.5
}
json
{
"success": true,
"message": "MLO weight saved successfully"
}
POST
/scavengers/save-plastic
Save plastic waste weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| weight | float | required | Weight in kg |
json
{"user_id": 1, "weight": 3.2}
POST
/scavengers/save-gabruk
Save Gabruk waste weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| weight | float | required | Weight in kg |
json
{"user_id": 1, "weight": 2.0}
POST
/scavengers/save-botol-plastik
Save botol plastik (plastic bottle) weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| weight | float | required | Weight in kg |
POST
/scavengers/save-kertas
Save kertas (paper) weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| weight | float | required | Weight in kg |
POST
/scavengers/save-kardus
Save kardus (cardboard) weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| weight | float | required | Weight in kg |
POST
/scavengers/save-botol-kaca
Save botol kaca (glass bottle) weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| weight | float | required | Weight in kg |
POST
/scavengers/save-aqua-gelas
Save aqua gelas (cup) weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| weight | float | required | Weight in kg |
POST
/scavengers/save-incenerator
Save incinerator waste weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| weight | float | required | Weight in kg |
POST
/scavengers/save-pirolisis
Save pirolisis (pyrolysis) waste weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| weight | float | required | Weight in kg |
POST
/scavengers/save-residu
Save residu (residue) weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | integer | required | Scavenger user ID |
| weight | float | required | Weight in kg |
DELETE
/scavengers/cache
Clear scavengers data cache (Admin only)
json
{
"success": true,
"message": "Cache cleared successfully"
}
Car Weight Management
POST
/addWeightData
Add vehicle weight data
| Parameter | Type | Required | Description |
|---|---|---|---|
| vehicle_id | integer | required | Vehicle ID |
| weight | float | required | Weight in kg |
| type | string | required | in/out |
POST
/weightDataIn
Record vehicle entry weight
| Parameter | Type | Required | Description |
|---|---|---|---|
| vehicle_id | integer | required | Vehicle ID |
| weight | float | required | Entry weight in kg |
POST
/weightDataOut
Record vehicle exit weight
| Parameter | Type | Required | Description |
|---|---|---|---|
| vehicle_id | integer | required | Vehicle ID |
| weight | float | required | Exit weight in kg |
GET
/getCustomer
Get all customers list
GET
/weight/data
Get vehicle weight data with filters
| Parameter | Type | Required | Description |
|---|---|---|---|
| period | string | optional | daily/weekly/monthly |
| driver_id | integer | optional | Filter by driver |
| customer_id | integer | optional | Filter by customer |
| limit | integer | optional (default: 20) | Max records |
Card Member Management
GET
/get-member
Get all scavenger card members
POST
/register-card-member
Register new card member
| Parameter | Type | Required | Description |
|---|---|---|---|
| card_uid | string | required | Card UID |
| name | string | required | Member name |
| phone | string | optional | Phone number |
GET
/getMember
Get member by ID
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | integer | required | Member ID |
Attendance Management
POST
/attendance
Record attendance
| Parameter | Type | Required | Description |
|---|---|---|---|
| uid | string | required | User UID |
| shift | string | required | Shift (morning/afternoon) |
GET
/attendance/list
Get all attendance records
GET
/attendance/today
Get today's attendance
GET
/attendance/user/{uid}
Get attendance by user UID
| Parameter | Type | Required | Description |
|---|---|---|---|
| uid | string | required | User UID |
GET
/attendance/stats
Get attendance statistics
| Parameter | Type | Required | Description |
|---|---|---|---|
| start_date | date | optional | Start date |
| end_date | date | optional | End date |
GET
/attendance/shift
Get attendance by shift
| Parameter | Type | Required | Description |
|---|---|---|---|
| shift | string | required | Shift type |
| date | date | optional | Specific date |
Weight Management
GET
/weight/data
Vehicle weight data with filtering
| Parameter | Type | Required | Description |
|---|---|---|---|
| period | string | optional | daily/weekly/monthly |
| driver_id | integer | optional | Filter by driver |
| customer_id | integer | optional | Filter by customer |
| limit | integer | optional (default: 20) | Max records |
GET
/getCustomer
List all registered customers
Temperature Monitoring
GET
/temp-data
Incinerator, dryer & pyrolysis temperatures
| Parameter | Type | Required | Description |
|---|---|---|---|
| range | string | optional | today|week|month |
| limit | integer | optional (default: 100) | Max records (max 1000) |
Jatisari API Endpoints
Biogas production monitoring and weight tracking for Jatisari location
Biogas Monitoring
POST
/biogas/jatisari/push
Ingest new sensor reading
| Parameter | Type | Required | Description |
|---|---|---|---|
| ph | float | required | pH of digester liquid |
| temp_liquid | float | required | Liquid temperature (°C) |
| temp_ambien | float | required | Ambient temperature (°C) |
| weight | float | required | Feed weight (kg) |
| gas_prod | float | required | Gas production (L/h) |
| temp_gas_prod | float | required | Gas prod temperature (°C) |
| pressure_gas_prod | float | required | Gas prod pressure (bar) |
| gas_used | float | required | Gas consumed (L/h) |
| temp_gas_used | float | required | Gas used temperature (°C) |
| pressure_gas_used | float | required | Gas used pressure (bar) |
| balloon_level_1 | float | optional | Balloon 1 level (%) |
| balloon_level_2 | float | optional | Balloon 2 level (%) |
| storage | float | optional | Storage volume (m³) |
GET
/biogas/jatisari/latest
Latest biogas reading
GET
/biogas/jatisari/history
Time-series data by hour window
| Parameter | Type | Required | Description |
|---|---|---|---|
| hours | integer | optional (default: 24) | Look-back window in hours |
GET
/biogas/jatisari/stats
Aggregate stats over N days
| Parameter | Type | Required | Description |
|---|---|---|---|
| days | integer | optional (default: 7) | Number of days to aggregate |
Weight Monitoring
POST
/weight/push
Push weight reading from scale
| Parameter | Type | Required | Description |
|---|---|---|---|
| weight | float | required | Weight value in kg (min: 1) |
GET
/weight/latest
Latest weight reading
GET
/weight/history
Weight history by hour window
| Parameter | Type | Required | Description |
|---|---|---|---|
| hours | integer | optional (default: 24) | Look-back window in hours |
GET
/weight/stats
Weight statistics over N days
| Parameter | Type | Required | Description |
|---|---|---|---|
| days | integer | optional (default: 7) | Number of days to aggregate |
Indramayu API Endpoints
Biogas production and consumption monitoring for Indramayu site
Biogas Monitoring
POST
/biogas/indramayu/push
Ingest new sensor reading
| Parameter | Type | Required | Description |
|---|---|---|---|
| gas_prod | float | required | Gas production flow rate (L/h) |
| temp_gas_prod | float | required | Temperature at production point (°C) |
| press_gas_prod | float | required | Pressure at production point (bar) |
| gas_cons | float | required | Gas consumption flow rate (L/h) |
| temp_gas_cons | float | required | Temperature at consumption point (°C) |
| press_gas_cons | float | required | Pressure at consumption point (bar) |
GET
/biogas/indramayu/latest
Most recent sensor record
GET
/biogas/indramayu/history
Time-series data by hour window
| Parameter | Type | Required | Description |
|---|---|---|---|
| hours | integer | optional (default: 24) | Look-back window in hours |
| limit | integer | optional (default: 100) | Max rows returned (max 500) |
GET
/biogas/indramayu/stats
Aggregate stats over N days
| Parameter | Type | Required | Description |
|---|---|---|---|
| days | integer | optional (default: 7) | Number of days to aggregate |
HTTP Error Codes
400
Bad Request — Invalid parameters or validation failure
401
Unauthorized — Missing or invalid credentials
404
Not Found — Resource or location does not exist
429
Too Many Requests — Rate limit exceeded
500
Internal Server Error — Unexpected server-side failure
Quick Test — curl
bash
# ── Depok ───────────────────────────────────────────────
curl https://monitoring.xampah.com/api/biogas-data/latest
# Scavengers – list users today
curl "https://monitoring.xampah.com/api/scavengers/users?date=2024-01-15"
# Scavengers – detail for user 12
curl "https://monitoring.xampah.com/api/scavengers/users/12?date=2024-01-15"
# ── Jatisari ─────────────────────────────────────────────
curl https://monitoring.xampah.com/api/biogas/jatisari/latest
curl "https://monitoring.xampah.com/api/biogas/jatisari/history?hours=48"
curl "https://monitoring.xampah.com/api/biogas/jatisari/stats?days=7"
curl https://monitoring.xampah.com/api/weight/latest
# ── Indramayu ────────────────────────────────────────────
curl https://monitoring.xampah.com/api/biogas/indramayu/latest
curl "https://monitoring.xampah.com/api/biogas/indramayu/history?hours=24&limit=50"
curl "https://monitoring.xampah.com/api/biogas/indramayu/stats?days=7"
# Push Indramayu sensor data
curl -X POST https://monitoring.xampah.com/api/biogas/indramayu/push \
-H "Content-Type: application/json" \
-d '{"gas_prod":120.5,"temp_gas_prod":45.2,"press_gas_prod":2.5,"gas_cons":85.3,"temp_gas_cons":42.1,"press_gas_cons":2.1}'