Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Acompanhe o processamento e acesse os dados extraídos
GET /v2/file_uploads/:id
{ "object": "file_upload", "id": "fu_abc123", "status": "uploaded", "parsing": { "status": "completed", "template": "balance_sheet", "confidence": 0.95, "started_time": "2024-12-07T11:01:00.000Z", "completed_time": "2024-12-07T11:02:30.000Z" }, "parsed_data": {} }
parsing.status
parsing.template
balance_sheet
parsing.confidence
parsing.started_time
parsing.completed_time
parsing.error
income_statement
invoice
no_template
async function waitForProcessing(fileId, token, maxAttempts = 30) { for (let i = 0; i < maxAttempts; i++) { const response = await fetch( `https://api.base39.com.br/v2/file_uploads/${fileId}`, { headers: { Authorization: `Bearer ${token}` }, } ); const data = await response.json(); if (data.parsing.status === "completed") { return data; } if (data.parsing.status === "failed") { throw new Error(data.parsing.error); } await new Promise((r) => setTimeout(r, 2000)); } throw new Error("Timeout"); }
const fileUpload = await waitForProcessing(fileId, token); if (fileUpload.parsed_data) { const response = await fetch(fileUpload.parsed_data); const data = await response.json(); // Acessar primeira empresa e período const company = data.companies[0]; const period = company.periods[0]; console.log("Empresa:", company.company_name); console.log("Ativo total:", period.assets.value); console.log("Passivo total:", period.liabilities.value); console.log("Patrimônio Líquido:", period.equity.value); }