API Overview
articwake provides a REST API for programmatic control of Wake-on-LAN and LUKS unlock operations.
Base URL
Section titled “Base URL”http://<articwake-host>Endpoints
Section titled “Endpoints”| Endpoint | Method | Auth | Description |
|---|---|---|---|
/ | GET | No | Serve embedded web UI |
/api/auth | POST | No | Verify PIN, return bearer token |
/api/status | GET | Yes | Server reachability and SSH port status |
/api/wol | POST | Yes | Send Wake-on-LAN magic packet |
/api/unlock | POST | Yes | Send LUKS passphrase via SSH |
Authentication
Section titled “Authentication”Protected endpoints require a bearer token in the Authorization header.
Getting a token
Section titled “Getting a token”curl -X POST http://localhost/api/auth \ -H "Content-Type: application/json" \ -d '{"pin": "your-pin"}'Response:
{ "token": "a1b2c3d4e5f6..."}Using a token
Section titled “Using a token”curl http://localhost/api/status \ -H "Authorization: Bearer a1b2c3d4e5f6..."Token expiry
Section titled “Token expiry”Tokens are valid for 15 minutes from creation. After expiry, you’ll receive a 401 Unauthorized response and need to re-authenticate.
Rate Limiting
Section titled “Rate Limiting”The /api/auth endpoint is rate limited to 10 attempts per minute per IP address. Exceeding this limit returns 429 Too Many Requests.
Error Responses
Section titled “Error Responses”All error responses follow this format:
{ "error": "Error message describing what went wrong"}HTTP Status Codes
Section titled “HTTP Status Codes”| Code | Meaning |
|---|---|
200 | Success |
400 | Bad request (invalid input) |
401 | Unauthorized (invalid/expired token or wrong PIN) |
429 | Rate limited |
500 | Internal server error |
Content Types
Section titled “Content Types”- Request bodies:
application/json - Response bodies:
application/json
Example Workflow
Section titled “Example Workflow”# 1. AuthenticateTOKEN=$(curl -s -X POST http://localhost/api/auth \ -H "Content-Type: application/json" \ -d '{"pin": "1234"}' | jq -r '.token')
# 2. Check statuscurl -s http://localhost/api/status \ -H "Authorization: Bearer $TOKEN" | jq
# 3. Wake the servercurl -s -X POST http://localhost/api/wol \ -H "Authorization: Bearer $TOKEN" | jq
# 4. Wait for boot, then unlocksleep 30curl -s -X POST http://localhost/api/unlock \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"passphrase": "my-luks-passphrase"}' | jq