Skip to content

SDKs

Official SDKs for popular programming languages.


Available SDKs

  • JavaScript/TypeScript


    Full-featured SDK with TypeScript support

    Installation:

    npm install @archivus/sdk
    

    JavaScript SDK

  • Python


    Pythonic interface with async support

    Installation:

    pip install archivus
    

    Python SDK

  • Go


    Idiomatic Go client with context support

    Installation:

    go get github.com/archivus/archivus-go
    

    Go SDK


Quick Comparison

Feature JavaScript Python Go
Type Safety TypeScript Type hints Built-in
Async/Await Goroutines
Streaming
Error Handling Promises/try-catch Exceptions Error returns
Auto-retry
Webhook Verification

Quick Start

JavaScript

import { ArchivusClient } from '@archivus/sdk';

const client = new ArchivusClient({
  apiKey: process.env.ARCHIVUS_API_KEY,
  tenant: 'your-tenant'
});

// Upload and process a document
const document = await client.documents.upload({
  file: fs.createReadStream('contract.pdf'),
  enableAI: true
});

// Search documents
const results = await client.search.query('contract terms', {
  mode: 'semantic',
  limit: 10
});

// Chat with a document
const session = await client.chat.createSession({
  documentId: document.id
});

const answer = await client.chat.ask(session.id, 'What are the key terms?');
console.log(answer.content);

Python

from archivus import ArchivusClient

client = ArchivusClient(
    api_key=os.environ['ARCHIVUS_API_KEY'],
    tenant='your-tenant'
)

# Upload and process a document
with open('contract.pdf', 'rb') as f:
    document = client.documents.upload(file=f, enable_ai=True)

# Search documents
results = client.search.query('contract terms', mode='semantic', limit=10)

# Chat with a document
session = client.chat.create_session(document_id=document.id)
answer = client.chat.ask(session.id, 'What are the key terms?')
print(answer.content)

Go

package main

import (
    "context"
    "github.com/archivus/archivus-go"
)

func main() {
    client := archivus.NewClient(
        os.Getenv("ARCHIVUS_API_KEY"),
        "your-tenant",
    )

    ctx := context.Background()

    // Upload and process a document
    file, _ := os.Open("contract.pdf")
    document, _ := client.Documents.Upload(ctx, &archivus.UploadOptions{
        File: file,
        EnableAI: true,
    })

    // Search documents
    results, _ := client.Search.Query(ctx, "contract terms", &archivus.SearchOptions{
        Mode: "semantic",
        Limit: 10,
    })

    // Chat with a document
    session, _ := client.Chat.CreateSession(ctx, &archivus.ChatSessionOptions{
        DocumentID: document.ID,
    })

    answer, _ := client.Chat.Ask(ctx, session.ID, "What are the key terms?")
    fmt.Println(answer.Content)
}

Common Features

All SDKs provide:

Automatic Retry Logic

Automatically retry failed requests with exponential backoff:

// Configurable retry options
const client = new ArchivusClient({
  apiKey: 'your-api-key',
  tenant: 'your-tenant',
  maxRetries: 3,
  retryDelay: 1000  // Initial delay in ms
});

Rate Limit Handling

Automatically handle rate limits by waiting for reset:

// SDK automatically waits when rate limited
const documents = await client.documents.list();

Type Safety

TypeScript/type hints for better IDE support:

// TypeScript
import { Document, SearchResult } from '@archivus/sdk';

const doc: Document = await client.documents.get('doc_abc123');
const results: SearchResult[] = await client.search.query('query');

Streaming Support

Stream large responses:

// Stream document download
const stream = await client.documents.downloadStream('doc_abc123');
stream.pipe(fs.createWriteStream('output.pdf'));

Webhook Verification

Built-in webhook signature verification:

import { verifyWebhookSignature } from '@archivus/sdk';

app.post('/webhook', (req, res) => {
  const signature = req.headers['x-archivus-signature'];
  const isValid = verifyWebhookSignature(req.body, signature, webhookSecret);

  if (!isValid) {
    return res.status(401).send('Invalid signature');
  }

  // Process webhook
  handleWebhook(req.body);
  res.json({ status: 'ok' });
});

Installation

JavaScript/TypeScript

npm install @archivus/sdk

# or with yarn
yarn add @archivus/sdk

# or with pnpm
pnpm add @archivus/sdk

Python

pip install archivus

# or with poetry
poetry add archivus

# or with pipenv
pipenv install archivus

Go

go get github.com/archivus/archivus-go

Authentication

All SDKs support both authentication methods:

const client = new ArchivusClient({
  apiKey: 'ak_live_YOUR_API_KEY',
  tenant: 'your-tenant'
});

JWT Token

const client = new ArchivusClient({
  token: 'your-jwt-token',
  tenant: 'your-tenant'
});

// Automatically refresh tokens
client.on('tokenRefresh', (newToken) => {
  saveToken(newToken);
});

Error Handling

All SDKs provide structured error handling:

try {
  const document = await client.documents.get('doc_abc123');
} catch (error) {
  if (error instanceof ArchivusError) {
    console.error('Error code:', error.code);
    console.error('Error message:', error.message);
    console.error('Error details:', error.details);
  }
}

Support

  • Documentation: Comprehensive guides and API reference
  • GitHub Issues: Report bugs or request features
  • Examples: Sample code in each SDK repository
  • Community: Join our Discord for help and discussion

Next Steps

Choose your SDK and get started:

  • JavaScript/TypeScript


    Full-featured SDK with examples

    JavaScript SDK

  • Python


    Pythonic interface with examples

    Python SDK

  • Go


    Idiomatic Go client with examples

    Go SDK