Overview

DataBridge provides a RESTful API for document operations. While most users will interact through our Python SDK, you can use the API directly from any language.

Base URL

For local development:

http://localhost:8000

Authentication

Note: If you're running DataBridge in development mode (dev_mode=true in databridge.toml), authentication is not required and you can skip this section.

In production mode, all requests require a JWT token in the Authorization header:

Authorization: Bearer eyJhbGciOiJS...

To get your authentication token:

  1. Visit the API documentation at http://localhost:8000/docs

  2. Find the /local/generate_uri endpoint

  3. Use the endpoint to generate a URI containing your token

  4. Extract the token portion from the URI (the part between : and @)

The generated URI will be in the format: databridge://owner_id:token@host:port

Core Operations

Document Management

  • POST /ingest/text - Ingest text documents

  • POST /ingest/file - Ingest file documents

  • GET /documents - List documents with pagination and filtering

    • Query Parameters:

      • skip (optional): Number of documents to skip (default: 0)

      • limit (optional): Maximum number of documents to return (default: 100)

      • filters (optional): Metadata filters in JSON format

  • GET /documents/{id} - Get document details

Search & Retrieval

  • POST /query - Generate AI completions using relevant document context

    • Parameters:

      • query: The question or prompt

      • filters (optional): Metadata filters

      • k (optional): Number of chunks to use as context (default: 4)

      • min_score (optional): Minimum similarity score (default: 0.0)

      • max_tokens (optional): Maximum tokens in completion

      • temperature (optional): Sampling temperature for completion

  • POST /retrieve/chunks - Search for relevant document chunks

    • Parameters:

      • query: The search query

      • filters (optional): Metadata filters

      • k (optional): Number of chunks to return (default: 4)

      • min_score (optional): Minimum similarity score (default: 0.0)

  • POST /retrieve/docs - Search for relevant documents

    • Parameters:

      • Same as /retrieve/chunks

Usage & Telemetry

  • GET /usage/stats - Get usage statistics for the authenticated user

  • GET /usage/recent - Get recent usage records

    • Query Parameters:

      • operation_type (optional): Filter by operation type

      • since (optional): Filter by timestamp

      • status (optional): Filter by operation status

Request/Response Format

All requests and responses use JSON, except for file uploads which use multipart/form-data.

Example Text Ingestion Request

Example Query Request

Example Query Response

Example Retrieve Chunks Request

Example Retrieve Chunks Response

Example Usage Stats Response

Example Recent Usage Response

Common Response Codes

Code
Description

200

Success

400

Bad Request - Check request parameters

401

Unauthorized - Invalid/missing token

403

Forbidden - Insufficient permissions

404

Not Found

422

Validation Error

500

Internal Server Error

Available SDKs

  • Python SDK - Official Python client with both sync and async support

Last updated