Documentation Index
Fetch the complete documentation index at: https://developers.factify.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The SDK supports streaming file uploads to avoid loading entire files into memory. This is recommended for large files.
Basic Upload
import { Factify } from "@factify/sdk";
import { openAsBlob } from "node:fs";
const factify = new Factify({
bearerAuth: process.env.FACTIFY_KEY,
});
async function run() {
const result = await factify.documents.create({
payload: await openAsBlob("./contract.pdf"),
title: "Q4 Agreement",
});
console.log(result);
}
run();
File Handles by Runtime
Depending on your JavaScript runtime, use these utilities to get a file handle without reading the entire file into memory:
| Runtime | Method | Example |
|---|
| Node.js 20+ | openAsBlob from node:fs | await openAsBlob("./file.pdf") |
| Bun | Bun.file | Bun.file("./file.pdf") |
| Browsers | <input type="file"> | Returns a File instance |
| Node.js 18 | fileFrom from fetch-blob/from.js | fileFrom("./file.pdf") |
Node.js 20+ Example
import { Factify } from "@factify/sdk";
import { openAsBlob } from "node:fs";
const factify = new Factify({ bearerAuth: process.env.FACTIFY_KEY });
const result = await factify.documents.create({
payload: await openAsBlob("./contract.pdf"),
title: "Q4 Agreement",
});
Bun Example
import { Factify } from "@factify/sdk";
const factify = new Factify({ bearerAuth: process.env.FACTIFY_KEY });
const result = await factify.documents.create({
payload: Bun.file("./contract.pdf"),
title: "Q4 Agreement",
});
Browser Example
import { Factify } from "@factify/sdk";
const factify = new Factify({ bearerAuth: process.env.FACTIFY_KEY });
// Get file from input element
const input = document.querySelector('input[type="file"]') as HTMLInputElement;
const file = input.files?.[0];
if (file) {
const result = await factify.documents.create({
payload: file,
title: file.name,
});
}
Node.js 18 Example
import { Factify } from "@factify/sdk";
import { fileFrom } from "fetch-blob/from.js";
const factify = new Factify({ bearerAuth: process.env.FACTIFY_KEY });
const result = await factify.documents.create({
payload: await fileFrom("./contract.pdf"),
title: "Q4 Agreement",
});
Supported File Types
Currently, Factify supports PDF files only.
| File Type | MIME Type | Max Size |
|---|
| PDF | application/pdf | 100 MB |
Uploading non-PDF files will result in an invalid_file_type error.