Mining/site-docs/api/rest-api.md
snider 3057701ac1 feat: Add SQLite persistence, enhanced dashboard UI, and comprehensive E2E tests
- Add SQLite database package for hashrate history persistence with configurable retention
- Enhance dashboard with responsive stats bar, improved chart component, and worker selector
- Add terminal modal component for console output viewing
- Implement comprehensive E2E test suite with page objects pattern
- Add history API endpoints for historical data queries
- Update worker message handling with proper registration
- Add new UI pages structure with layouts and components
- Update Docker configuration for Go 1.24
- Add PostCSS configuration for Tailwind CSS processing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:03:30 +00:00

2 KiB

REST API

The Mining Dashboard exposes a RESTful API for programmatic access.

Base URL

http://localhost:9090/api/v1/mining

Authentication

Currently, the API does not require authentication. It's designed to run on a local network.

!!! warning "Security" Do not expose port 9090 to the public internet without additional security measures.

Response Format

All responses are JSON:

{
  "data": { ... },
  "error": null
}

Error responses:

{
  "error": "Error message here"
}

Swagger Documentation

Interactive API docs are available at:

http://localhost:9090/api/v1/mining/swagger/index.html

Common Headers

Header Value
Content-Type application/json
Accept application/json

HTTP Methods

Method Usage
GET Retrieve resources
POST Create resources or trigger actions
PUT Update resources
DELETE Remove resources

Error Codes

Code Meaning
200 Success
400 Bad request (invalid input)
404 Resource not found
500 Internal server error

Rate Limiting

No rate limiting is currently implemented.

Example: List Running Miners

curl http://localhost:9090/api/v1/mining/miners

Response:

[
  {
    "name": "xmrig-123",
    "running": true,
    "full_stats": {
      "hashrate": {
        "total": [1234.5, 1230.2, 1228.8]
      },
      "results": {
        "shares_good": 42,
        "shares_total": 43
      }
    }
  }
]

Example: Start a Miner

curl -X POST http://localhost:9090/api/v1/mining/profiles/abc123/start

Response:

{
  "name": "xmrig-456",
  "message": "Miner started successfully"
}

Example: Stop a Miner

curl -X DELETE http://localhost:9090/api/v1/mining/miners/xmrig-456

Response:

{
  "message": "Miner stopped"
}

WebSocket (Future)

A WebSocket endpoint for real-time updates is planned:

ws://localhost:9090/api/v1/mining/ws