Skip to main content

API Reference

Welcome to the OpenRAG API documentation. This REST API allows you to interact with the RAG system to upload documents, ask questions, and manage your collections.

Base URL

http://localhost:8000
In production, replace with your server’s URL.

Authentication

The current version does not require authentication. Authentication will be added in a future version for production.

Response Format

All API responses are in JSON format.
{
  "status": "success",
  "data": { ... }
}
In case of error:
{
  "detail": "Descriptive error message"
}
Content-Type: application/json
Accept: application/json

Rate Limiting

Currently, no rate limiting is applied. In production, a limit of 100 requests/minute per IP will be enforced.

Available Endpoints

Queries (RAG)

Document Management

Collections

System

GET /

API information

GET /health

Health check

HTTP Codes

CodeDescription
200Success
400Invalid request
404Resource not found
500Server error
504Timeout

Client Examples

Python

import requests

# Configuration
BASE_URL = "http://localhost:8000"

# Upload a document
with open("document.pdf", "rb") as f:
    response = requests.post(
        f"{BASE_URL}/documents/upload",
        files={"file": f}
    )
    print(response.json())

# Ask a question
response = requests.post(
    f"{BASE_URL}/query",
    json={
        "query": "What is the refund policy?",
        "max_results": 5
    }
)
print(response.json())

JavaScript/Node.js

const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

const BASE_URL = 'http://localhost:8000';

// Upload a document
async function uploadDocument() {
  const form = new FormData();
  form.append('file', fs.createReadStream('document.pdf'));
  
  const response = await axios.post(
    `${BASE_URL}/documents/upload`,
    form,
    { headers: form.getHeaders() }
  );
  
  console.log(response.data);
}

// Ask a question
async function query() {
  const response = await axios.post(
    `${BASE_URL}/query`,
    {
      query: 'What is the refund policy?',
      max_results: 5
    }
  );
  
  console.log(response.data);
}

cURL

# Health check
curl http://localhost:8000/health

# Upload a document
curl -X POST http://localhost:8000/documents/upload \
  -F "file=@document.pdf"

# Ask a question
curl -X POST http://localhost:8000/query \
  -H "Content-Type: application/json" \
  -d '{
    "query": "What is the refund policy?",
    "max_results": 5
  }'

# List documents
curl http://localhost:8000/documents

Interactive Documentation

OpenRAG provides interactive Swagger UI documentation accessible at:
http://localhost:8000/docs
You can directly test all endpoints there!

Webhooks (coming soon)

Webhooks will allow you to receive notifications when:
  • Document processing complete
  • Processing errors
  • New documents added

SDK (coming soon)

Official SDKs will soon be available for:
  • Python
  • JavaScript/TypeScript
  • Go
  • Java

Support

For any questions about the API: