SQLite Over HTTP Gateway

A fast, secure, C++ API Gateway for hosting user-isolated SQLite databases.

Version: v1.1.0

🔐 Authentication Endpoints

Manage user registration, authentication keys, and connection profile constraints.

POST/api/auth/register

Register a new user profile and allocate an isolated sandbox database.

{
  "email": "user@example.com",
  "password": "yourpassword",
  "domains": ["http://localhost:5173"]
}

POST/api/auth/login

Authenticate credentials and fetch session metadata along with your active API key.

{
  "email": "user@example.com",
  "password": "yourpassword"
}

POST/api/auth/update-password

Change your account password. Requires verification of your active old password.

{
  "oldPassword": "oldpassword123",
  "newPassword": "newsecurepassword123"
}

POST/api/auth/update-domains

Configure whitelisted CORS domains dynamically.

{
  "domains": [
    "https://my-domain.com",
    "http://localhost:5173"
  ]
}

POST/api/auth/update-timezone

Modify your account timezone offset or city code dynamically to configure datetime logging.

{
  "timezone": "Asia/Bangkok"
}

POST/api/auth/me

Fetch details about your registered user profile including User ID, Email, Whitelisted Domains, Timezone and active API Key.

POST/api/auth/revoke-key

Revokes your active API Key and returns a newly generated secure token immediately.

POST/api/auth/delete-account

Deletes your account completely, purging your system metadata and deleting your isolated SQLite database directory recursively from the host disk.

{
  "password": "yourpassword123"
}

⚙️ Dynamic Schema Endpoints

All schema routes require bearer API token authorization via header: Authorization: Bearer sk_your_api_key

POST/api/v1/create-table

Provisions a new table structure. System automatically prepends id (primary key) and appends created and updated timestamps.

{
  "table": "contacts",
  "columns": [
    { "name": "name", "type": "TEXT NOT NULL" },
    { "name": "phone", "type": "TEXT" }
  ]
}

POST/api/v1/create-tables

Provisions multiple table schemas atomically inside a single transaction. Excellent for setting up tables with relational foreign key structures in migrations.

{
  "tables": [
    {
      "table": "projects",
      "columns": [
        { "name": "title", "type": "TEXT NOT NULL" }
      ]
    },
    {
      "table": "tasks",
      "columns": [
        { "name": "description", "type": "TEXT NOT NULL" },
        { "name": "project_id", "type": "TEXT REFERENCES projects(id) ON DELETE CASCADE" }
      ]
    }
  ]
}

POST/api/v1/create-index

Creates a custom B-Tree search index on columns to optimize dynamic lookups.

{
  "index": "idx_contacts_name",
  "table": "contacts",
  "columns": ["name"],
  "unique": false
}

POST/api/v1/create-indexes

Provisions multiple table search indices atomically inside a single transaction. Great for indexing schemas in batch migrations.

{
  "indexes": [
    {
      "index": "idx_contacts_name",
      "table": "contacts",
      "columns": ["name"],
      "unique": false
    },
    {
      "index": "idx_projects_title",
      "table": "projects",
      "columns": ["title"],
      "unique": true
    }
  ]
}

POST/api/v1/create-trigger

Registers an event trigger in SQLite for automated reactive auditing.

{
  "trigger": "tg_contacts_delete_log",
  "event": "DELETE",
  "table": "contacts",
  "actionTable": "audit_logs",
  "actionData": {
    "task_id": "OLD.id",
    "action": "DELETED"
  }
}

📊 CRUD Execution Endpoints

All CRUD routes require bearer API token authorization via header: Authorization: Bearer sk_your_api_key

POST/api/v1/insert

Inserts a row into your table. Auto-injects a cryptographically secure 15-character ID. Supports an optional conflictTarget parameter to execute high-speed, native SQLite single-row UPSERTs.

{
  "table": "contacts",
  "conflictTarget": "name",
  "data": {
    "name": "Jane Doe",
    "phone": "+1-555-0199"
  }
}

POST/api/v1/inserts

Inserts multiple rows of data atomically inside a single transaction. Supports an optional conflictTarget parameter to execute high-speed, native SQLite UPSERTs (insert-or-update on conflicts).

{
  "table": "contacts",
  "conflictTarget": "name",
  "rows": [
    { "name": "Jane Doe", "phone": "+1-555-0199" },
    { "name": "Alan Turing", "phone": "+1-555-1954" }
  ]
}

POST/api/v1/query

Queries database records with clean filters.

{
  "table": "contacts",
  "select": ["id", "name", "phone"],
  "where": {
    "name": "Jane Doe"
  },
  "limit": 5
}

POST/api/v1/tables

Retrieves a list of all user-created tables in your sandboxed database along with their active row counts.

POST/api/v1/indexes

Retrieves a list of all active search indexes currently provisioned on your custom database tables.

POST/api/v1/triggers

Retrieves a list of all active event triggers configured on your tables.

POST/api/v1/stats

Retrieves a complete analytical metrics payload representing your database size (formatted in a human-readable string like 5.4MB), tables list (with active row counts), indexes, and triggers.

POST/api/v1/truncate

Truncates all rows in a table. Supports an optional foreignKeyCheck parameter (0 or 1) to temporarily toggle foreign key verification constraints during the operation.

{
  "table": "contacts",
  "foreignKeyCheck": 0
}

POST/api/v1/update

Updates records matching criteria. The system automatically maintains local timezone update tracking.

{
  "table": "contacts",
  "data": { "phone": "+1-555-9876" },
  "where": { "id": "yR5LBZgxfcxN086" }
}

POST/api/v1/delete

Deletes records matching criteria.

{
  "table": "contacts",
  "where": { "id": "yR5LBZgxfcxN086" }
}

POST/api/v1/alter-table

Alters a database table (rename table, rename column, or modify column type) using transaction-backed temporary schema recreations.

{
  "table": "contacts",
  "action": "modify_column",
  "column": "email",
  "type": "TEXT NOT NULL UNIQUE"
}

POST/api/v1/delete-table

Deletes (drops) a database table. Supports temporarily bypassing foreign key checks.

{
  "table": "contacts",
  "foreignKeyCheck": 0
}

📡 Public Health & System Check

System metrics and availability check. Unauthenticated and ready for monitoring pages.

GET/health

Returns high-level system availability health metrics and process uptime statistics.

{
  "status": "healthy",
  "uptime_seconds": 128450,
  "uptime_human": "1d 11h 40m 50s",
  "version": "1.1.0",
  "gateway": "C++ SQLite Gateway"
}

GET/ip

Returns the client's public IP address. Handles reverse-proxy chains (e.g. Nginx, Cloudflare) automatically.

{
  "ip": "180.244.135.210"
}