DocumentFlow

Getting Started with DocumentFlow

Welcome to DocumentFlow! This guide will help you get started with integrating DocumentFlow into your application. Follow these steps to begin processing documents and extracting data.

Installation

First, install the DocumentFlow SDK using your preferred package manager:

npm install documentflow-sdk

Quick Start

Here's a simple example to get you started with DocumentFlow. This example shows how to process a document and retrieve its data:

// Note: This is a simplified example for demonstration purposes.
// In a real-world scenario, you'd want to use proper async handling and error checking.

const DocumentFlow = {
  Client: function(apiKey) {
    this.apiKey = apiKey;
    this.documents = {
      process: async function(options) {
        console.log('Processing document:', options);
        return { id: 'doc_123', status: 'processing' };
      },
      get: async function(id) {
        console.log('Getting document:', id);
        return {
          id: id,
          status: 'completed',
          results: {
            total_amount: 1000,
            currency: 'USD',
            invoice_number: 'INV-001',
            issue_date: '2024-01-23',
            due_date: '2024-02-23',
            vendor: {
              name: 'Acme Corp',
              tax_id: '123456789'
            }
          }
        };
      }
    };
  }
};

// Initialize the client with your API key
const documentFlow = new DocumentFlow.Client(apiToken);

// Process a document
async function processDocument() {
  try {
    // Submit document for processing
    const document = await documentFlow.documents.process({
      url: 'https://example.com/invoice.pdf',
      type: 'invoice'
    });
    
    console.log('Processing started:', document.id);
    
    // In a real scenario, you'd want to implement proper polling or use webhooks
    // This is a simplified example
    const result = await documentFlow.documents.get(document.id);
    console.log('Processing complete:', result);
    
    // Access extracted data
    const {
      total_amount,
      currency,
      invoice_number,
      issue_date,
      due_date,
      vendor
    } = result.results;
    
    console.log('Invoice total:', total_amount, currency);
    return result;
  } catch (error) {
    console.error('Error:', error.message);
    throw error;
  }
}

return processDocument();

Next Steps

Authentication

Learn how to authenticate your API requests and manage your API keys.

Read Authentication Guide →

API Endpoints

Explore the available API endpoints and their capabilities.

View API Endpoints →

Webhooks

Set up webhooks to receive real-time updates about your documents.

Setup Webhooks →

Error Handling

Learn how to handle errors and edge cases in your integration.

View Error Guide →