55 lines
1.3 KiB
Plaintext
55 lines
1.3 KiB
Plaintext
This API provides the following endpoints:
|
|
|
|
GET /data - Get all records with pagination
|
|
|
|
Query params: page, limit
|
|
|
|
GET /data/:id - Get a specific record by ID
|
|
|
|
POST /data - Create a new record
|
|
|
|
Body: { x, y, z }
|
|
|
|
PUT /data/:id - Update an existing record
|
|
|
|
Body: { x, y, z }
|
|
|
|
DELETE /data/:id - Delete a record
|
|
|
|
GET /data/search - Advanced search with filtering and sorting
|
|
|
|
Query params: min_x, max_x, min_y, max_y, min_z, max_z, start_time, end_time, sort_by, order
|
|
|
|
|
|
Example usage:
|
|
# Get all records (first page)
|
|
curl http://localhost:3000/data
|
|
|
|
# Get the single latest record
|
|
curl http://localhost:3000/latest_data
|
|
|
|
# Get the latest 5 records
|
|
curl http://localhost:3000/latest_data/5
|
|
|
|
# Get all records from the last 10 minutes
|
|
curl http://localhost:3000/latest_data/window?minutes=10
|
|
|
|
# Get specific record
|
|
curl http://localhost:3000/data/1
|
|
|
|
# Create new record
|
|
curl -X POST http://localhost:3000/data \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"x": 1.5, "y": 2.3, "z": 3.7}'
|
|
|
|
# Update record
|
|
curl -X PUT http://localhost:3000/data/1 \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"x": 1.6, "y": 2.4, "z": 3.8}'
|
|
|
|
# Delete record
|
|
curl -X DELETE http://localhost:3000/data/1
|
|
|
|
# Advanced search
|
|
curl http://localhost:3000/data/search?min_x=1&max_x=5&sort_by=time&order=DESC
|