Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tiders

Tiders x402 Server

Tiders x402 Server is a payment-enabled database API server that combines DuckDB with the x402 payment protocol to create a pay-per-query data marketplace.

Data providers can expose DuckDB tables through a REST API where each query requires a cryptocurrency micropayment. Pricing is calculated per row returned, with support for tiered pricing based on result size.

Key Features

  • Pay-per-query data access – Charge users fixed or per row of data returned using cryptocurrency micropayments.
  • x402 protocol integration – Standard HTTP 402 Payment Required flow with automatic payment negotiation.
  • DuckDB backend – Fast, in-process analytical database with no separate database server required.
  • Apache Arrow responses – Efficient columnar data transfer using Arrow IPC format instead of JSON.
  • Tiered pricing – Multiple price tiers based on the number of rows requested (e.g., bulk discounts).
  • Multi-language support – Rust server with Python bindings (via PyO3).
  • Familiar SQL for Requests – A safe SQL subset that prevents expensive operations like JOINs, GROUP BY, and subqueries.

How It Works

  1. A client sends a SQL query to the server.
  2. The server parses and validates the query, then estimates the payment options.
  3. If payment is required, the server responds with HTTP 402 and payment options.
  4. The client signs a payment using their crypto wallet and resends the request with an X-Payment header.
  5. The server verifies and settles the payment through a facilitator, then returns the query results as Arrow IPC.

Project Structure

tiders-x402-server/
  server/          # Rust server (Axum-based REST API)
  python/          # Python bindings via PyO3 + maturin
  examples         # Python and Rust server examples
  client-scripts/  # Python and TypeScript clients scripts using x402-fetch
  docs/            # MDbook documentation page
  Cargo.toml       # Workspace configuration

Technology Stack

ComponentTechnology
Web frameworkAxum
DatabaseDuckDB, ClickHouse, PostgreSQL
Async runtimeTokio
Payment protocolx402 (via x402-rs)
Data serializationApache Arrow IPC
SQL parsingsqlparser
Blockchain primitivesAlloy
ObservabilityOpenTelemetry + tracing
Python FFIPyO3