API Overview

Introduction to the SNAP REST API and authentication methods.

API Base URL

http://localhost:8000

Authentication

SNAP uses token-based authentication. Include the token in the Authorization header:

curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8000/api/endpoint

Getting an Authentication Token

  1. Login via API:
    curl -X POST http://localhost:8000/config/user/login \
      -H "Content-Type: application/json" \
      -d '{
        "username": "admin",
        "password": "securepassword"
      }'
    
  2. Response:
    {
      "success": true,
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
      "user": {
        "username": "admin",
        "role": "administrator"
      }
    }
    
  3. Use the token:
    curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
      http://localhost:8000/checkpoint/list
    

API Endpoints Overview

Checkpoint Endpoints

Cluster Endpoints

Registry Endpoints

Configuration Endpoints

Response Format

All API responses follow this format:

Success Response

{
  "success": true,
  "data": {
    "checkpoint_id": "checkpoint-123",
    "status": "completed"
  },
  "message": "Operation completed successfully"
}

Error Response

{
  "success": false,
  "error": "Error message",
  "details": "Detailed error information",
  "code": "ERROR_CODE"
}

Error Codes

Rate Limiting

API requests are rate-limited:

Rate limit headers:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1642233600

WebSocket Support

Real-time updates via WebSocket:

const ws = new WebSocket('ws://localhost:8000/ws/progress');
ws.onmessage = function(event) {
  const data = JSON.parse(event.data);
  console.log('Progress:', data);
};

API Documentation

Interactive API documentation is available at: