Skip to main content

Overview

doXmind provides a comprehensive SDK and REST API for developers to integrate intelligent document processing into their applications.

SDK Installation

Install the doXmind SDK for your preferred language:
npm install @doxmind/sdk
# or
yarn add @doxmind/sdk

Configuration

Environment Setup

Create a .env file in your project root:
DOCMIND_API_KEY=your_api_key_here
DOCMIND_API_URL=https://api.doxmind.com/v1
DOCMIND_WORKSPACE_ID=your_workspace_id

Initialize the Client

import { doXmind } from '@doxmind/sdk';

const client = new doXmind({
  apiKey: process.env.DOCMIND_API_KEY,
  workspace: process.env.DOCMIND_WORKSPACE_ID
});

Core Concepts

Documents

Documents are the primary objects in doXmind:
// Create a document
const doc = await client.documents.create({
  title: 'Q4 Financial Report',
  type: 'report',
  metadata: {
    department: 'finance',
    quarter: 'Q4',
    year: 2024
  }
});

// Update document content
await client.documents.update(doc.id, {
  content: 'Your document content here...'
});

// Get document
const document = await client.documents.get(doc.id);

AI Operations

Leverage AI capabilities for document enhancement:
// Enhance writing
const enhanced = await client.ai.enhance({
  documentId: doc.id,
  instruction: 'Make this more concise and professional'
});

// Generate content
const generated = await client.ai.generate({
  prompt: 'Write an executive summary for Q4 financial results',
  context: document.content,
  maxTokens: 500
});

// Extract insights
const insights = await client.ai.analyze({
  documentId: doc.id,
  analysisType: 'key-points'
});

Templates

Work with document templates:
// List available templates
const templates = await client.templates.list({
  type: 'report',
  category: 'business'
});

// Create document from template
const fromTemplate = await client.documents.createFromTemplate({
  templateId: 'tmpl_financial_report',
  data: {
    company: 'Acme Corp',
    period: 'Q4 2024',
    revenue: 1500000
  }
});

Advanced Features

Batch Processing

Process multiple documents efficiently:
const batch = await client.batch.create({
  operations: [
    {
      type: 'enhance',
      documentIds: ['doc_1', 'doc_2', 'doc_3'],
      instruction: 'Fix grammar and improve clarity'
    },
    {
      type: 'translate',
      documentIds: ['doc_4', 'doc_5'],
      targetLanguage: 'es'
    }
  ]
});

// Check batch status
const status = await client.batch.getStatus(batch.id);

Webhooks

Set up webhooks for real-time updates:
// Register webhook
const webhook = await client.webhooks.create({
  url: 'https://your-app.com/webhooks/docmind',
  events: ['document.created', 'document.updated', 'ai.completed'],
  secret: 'your_webhook_secret'
});

// Verify webhook signature (in your webhook handler)
const isValid = client.webhooks.verifySignature(
  request.body,
  request.headers['x-docmind-signature'],
  'your_webhook_secret'
);

Custom Models

Use custom AI models for specialized tasks:
// Configure custom model
const customModel = await client.models.create({
  name: 'legal-document-analyzer',
  baseModel: 'docmind-large',
  finetuneData: 'gs://your-bucket/training-data'
});

// Use custom model
const analysis = await client.ai.analyze({
  documentId: doc.id,
  modelId: customModel.id,
  analysisType: 'legal-compliance'
});

Error Handling

Properly handle errors in your application:
try {
  const document = await client.documents.create({
    title: 'New Document'
  });
} catch (error) {
  if (error.code === 'RATE_LIMIT_EXCEEDED') {
    // Handle rate limiting
    console.log(`Rate limited. Retry after ${error.retryAfter} seconds`);
  } else if (error.code === 'INVALID_REQUEST') {
    // Handle validation errors
    console.log('Invalid request:', error.message);
  } else {
    // Handle other errors
    console.error('Unexpected error:', error);
  }
}

Best Practices

  • Never commit API keys to version control
  • Use environment variables or secret management services
  • Rotate keys regularly
  • Use restricted keys for production
  • Implement exponential backoff for retries
  • Use batch operations when possible
  • Cache responses when appropriate
  • Monitor your usage dashboard
  • Use pagination for large result sets
  • Implement proper caching strategies
  • Use webhooks instead of polling
  • Optimize document sizes

Examples

Full Example: Report Generator

import { doXmind } from '@doxmind/sdk';

async function generateMonthlyReport(data) {
  const client = new doXmind({
    apiKey: process.env.DOCMIND_API_KEY
  });

  try {
    // Create document from template
    const doc = await client.documents.createFromTemplate({
      templateId: 'tmpl_monthly_report',
      data: {
        month: data.month,
        metrics: data.metrics
      }
    });

    // Enhance with AI
    await client.ai.enhance({
      documentId: doc.id,
      instruction: 'Add executive summary and key insights'
    });

    // Generate charts
    const charts = await client.visualizations.create({
      documentId: doc.id,
      type: 'auto',
      data: data.metrics
    });

    // Export as PDF
    const pdf = await client.documents.export({
      documentId: doc.id,
      format: 'pdf',
      includeCharts: true
    });

    return {
      documentId: doc.id,
      pdfUrl: pdf.url
    };
  } catch (error) {
    console.error('Report generation failed:', error);
    throw error;
  }
}

Resources