ScoutExtract Docs

SDK Examples

Installation

Python:

pip install https://api.ramlabs.dev/sdks/python/download

Node.js / TypeScript:

npm install https://api.ramlabs.dev/sdks/node/download

Python — Using the SDK

from docex import DocEx

client = DocEx(api_key="rex_your_api_key")

Extract from text

result = client.extract( "Invoice #1234\nDate: 2024-01-15\nVendor: Acme Corp\nTotal: $1,500.00", "invoice" ) print(f"Vendor: {result.data['vendor_name']}")

Extract from file

result = client.extract_file("invoice.pdf", "invoice")

Node.js — Using the SDK

import DocEx from "docex";

const client = new DocEx({ apiKey: "rex_your_api_key" });

const result = await client.extract( "Invoice #1234\nDate: 2024-01-15\nVendor: Acme Corp\nTotal: $1,500.00", "invoice" ); console.log(result.data.vendor_name);

const fileResult = await client.extractFile("invoice.pdf", "invoice");

Python — Using requests directly

import requests

API_KEY = "rex_your_api_key" BASE_URL = "https://api.ramlabs.dev"

response = requests.post( f"{BASE_URL}/v1/extract", headers={"Authorization": f"Bearer {API_KEY}"}, json={ "document": "Invoice #1234\nDate: 2024-01-15\nVendor: Acme Corp\nTotal: $1,500.00", "schema": "invoice", }, ) result = response.json() print(f"Vendor: {result['data']['vendor_name']}")

Node.js — Using fetch directly

const API_KEY = "rex_your_api_key";
const BASE_URL = "https://api.ramlabs.dev";

const response = await fetch(\\${BASE_URL}/v1/extract\, { method: "POST", headers: { Authorization: \Bearer \${API_KEY}\, "Content-Type": "application/json", }, body: JSON.stringify({ document: "Invoice #1234\nDate: 2024-01-15\nVendor: Acme Corp\nTotal: $1,500.00", schema: "invoice", }), }); const result = await response.json(); console.log(result.data.vendor_name);