.do
Api

Database API

REST API reference for database.do - A structured collection of data organized for efficient storage, retrieval, and management.

Database API

A structured collection of data organized for efficient storage, retrieval, and management.

Endpoint

Authentication

All API requests require authentication:

curl https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

Request

Headers

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
X-Request-ID: unique-request-id (optional)

Request Body

{
  "operation": "database",
  "parameters": {
    // Operation-specific parameters
  },
  "options": {
    "timeout": 30000,
    "retries": 3
  }
}

Response

Success Response

{
  "success": true,
  "data": {
    // Response data
  },
  "meta": {
    "requestId": "req_123",
    "timestamp": "2025-01-01T12:00:00Z",
    "duration": 145
  }
}

Error Response

{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid parameters",
    "details": {
      // Error details
    }
  },
  "meta": {
    "requestId": "req_123",
    "timestamp": "2025-01-01T12:00:00Z"
  }
}

Operations

create

Initialize a new database with specified schema and configuration.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "create",
    "parameters": {}
  }'

update

Modify database configuration, schema, or settings.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "update",
    "parameters": {}
  }'

delete

Permanently remove the database and all contained data.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "delete",
    "parameters": {}
  }'

backup

Create a point-in-time snapshot for disaster recovery.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "backup",
    "parameters": {}
  }'

restore

Recover database data from a previous backup snapshot.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "restore",
    "parameters": {}
  }'

migrate

Transfer database to a different version, engine, or location.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "migrate",
    "parameters": {}
  }'

query

Execute read operations to retrieve data.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "query",
    "parameters": {}
  }'

insert

Add new records or documents.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "insert",
    "parameters": {}
  }'

updateRecords

Modify existing records or documents.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "updateRecords",
    "parameters": {}
  }'

deleteRecords

Remove records matching specified criteria.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "deleteRecords",
    "parameters": {}
  }'

index

Create optimized data structures to accelerate queries.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "index",
    "parameters": {}
  }'

optimize

Improve performance through tuning or resource allocation.

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "optimize",
    "parameters": {}
  }'

Examples

cURL

curl -X POST https://api.do/database \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "database",
    "parameters": {}
  }'

JavaScript/TypeScript

const response = await fetch('https://api.do/database', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    operation: 'database',
    parameters: {},
  }),
})

const data = await response.json()

Python

import requests

response = requests.post(
    'https://api.do/database',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
    },
    json={
        'operation': 'database',
        'parameters': {}
    }
)

data = response.json()

Rate Limiting

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

Status Codes

  • 200 OK - Success
  • 400 Bad Request - Invalid request
  • 401 Unauthorized - Missing/invalid API key
  • 403 Forbidden - Insufficient permissions
  • 404 Not Found - Resource not found
  • 429 Too Many Requests - Rate limit exceeded
  • 500 Internal Server Error - Server error
  • 503 Service Unavailable - Service temporarily unavailable

Error Codes

  • VALIDATION_ERROR - Invalid parameters
  • AUTHENTICATION_ERROR - Invalid API key
  • AUTHORIZATION_ERROR - Insufficient permissions
  • NOT_FOUND - Resource not found
  • RATE_LIMIT_EXCEEDED - Too many requests
  • TIMEOUT - Operation timeout
  • INTERNAL_ERROR - Server error

Webhooks

Subscribe to events:

curl -X POST https://api.do/webhooks \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-app.com/webhook",
    "events": ["database.created", "database.updated", "database.deleted", "database.backedUp", "database.restored", "database.migrated", "database.queried", "database.inserted", "database.recordsUpdated", "database.recordsDeleted", "database.indexed", "database.optimized", "database.connectionLimitReached", "database.error"]
  }'

Best Practices

  1. API Keys - Store securely, never commit to git
  2. Error Handling - Handle all error codes gracefully
  3. Retries - Implement exponential backoff
  4. Rate Limiting - Respect rate limits
  5. Idempotency - Use X-Idempotency-Key header
  6. Logging - Log requests for debugging