SmolAgent_Tutorial/URL_Database_project/backend_server
2025-03-03 16:35:52 +08:00
..
.gitignore add the Simple Agent Example Project 2025-03-03 16:35:52 +08:00
app.js add the Simple Agent Example Project 2025-03-03 16:35:52 +08:00
package-lock.json add the Simple Agent Example Project 2025-03-03 16:35:52 +08:00
package.json add the Simple Agent Example Project 2025-03-03 16:35:52 +08:00
readme add the Simple Agent Example Project 2025-03-03 16:35:52 +08:00

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