Getting Started
Quick Start
Process your first document with the LimAI API in four steps.
This guide walks you through the complete workflow to extract structured data from a document using the LimAI API.
Prerequisites
- A LimAI account with an API token
- An extraction schema (model) created in the LimAI dashboard
- A document to process (PDF, image, or Excel file)
Step 1: Get an Upload URL
Request a pre-signed URL and a fileId for your document.
const response = await fetch(
`https://app.limai.io/api/v1/document/${SCHEMA_ID}/get-url?filename=invoice.pdf`,
{
headers: { "Authorization": `Bearer ${API_TOKEN}` }
}
)
const { url, fileId } = await response.json()Step 2: Upload Your File
Upload the file directly to the pre-signed URL using a PUT request.
const fs = require("fs")
const fileData = fs.readFileSync("invoice.pdf")
await fetch(url, {
method: "PUT",
headers: { "Content-Type": "application/pdf" },
body: fileData
})Step 3: Process the Document
Trigger extraction on the uploaded file. Use the synchronous endpoint for small files or the async endpoint for larger documents.
Synchronous (waits for result)
const result = await fetch(
`https://app.limai.io/api/v1/document/${SCHEMA_ID}/process-file/${fileId}`,
{
method: "POST",
headers: {
"Authorization": `Bearer ${API_TOKEN}`,
"Content-Type": "application/json"
},
body: JSON.stringify({})
}
)
const extracted = await result.json()Asynchronous (returns job ID, poll for results)
const queueResponse = await fetch(
`https://app.limai.io/api/v1/document/${SCHEMA_ID}/process-file-async/${fileId}`,
{
method: "POST",
headers: {
"Authorization": `Bearer ${API_TOKEN}`,
"Content-Type": "application/json"
},
body: JSON.stringify({})
}
)
const { jobId } = await queueResponse.json()Step 4: Retrieve Results
For async processing, poll the get-file-data endpoint until the status is COMPLETED.
async function pollForResults(fileId) {
while (true) {
const response = await fetch(
`https://app.limai.io/api/v1/document/get-file-data?fileId=${fileId}`,
{ headers: { "Authorization": `Bearer ${API_TOKEN}` } }
)
const data = await response.json()
if (data.status === "COMPLETED") return data
if (data.status === "FAILED") throw new Error(data.errorMessage)
await new Promise(r => setTimeout(r, 5000))
}
}
const result = await pollForResults(fileId)
console.log(result.data.tables)Response200
{
"status": "COMPLETED",
"message": "File data retrieved successfully.",
"fileId": "file_abc123",
"data": {
"tables": {
"table_1": {
"id": "table_1",
"name": "Invoices",
"columns": [
{
"id": "col_1",
"name": "Invoice Number",
"type": "TEXT"
}
],
"rows": [
{
"id": "row_1",
"cells": {
"Invoice Number": {
"value": "INV-001",
"columnId": "col_1"
}
}
}
]
}
}
}
}Next Steps
- Document Processing API -- Full endpoint reference
- Classification API -- Automatically route documents to the right model
- Webhooks -- Get notified when processing completes