JavaScript
The Paperful JavaScript SDK provides a typed interface for interacting with the Paperful API from JavaScript and TypeScript applications.
It works with modern server runtimes including Node.js and Bun.
Installation
The Paperful JavaScript SDK is available on npm.
npm
View package versions, release information, and installation details.
Source Code
View the source code, contribute, and explore the repository.
Install the SDK using your preferred package manager.
npm install @paperful/sdk Create a client
Initialize the SDK with your API key:
import { Paperful } from "@paperful/sdk";
const paperful = new Paperful({
// optional: provide your API key here if not using environment variables
apiKey: "pf_..."
}); TypeScript
The JavaScript SDK includes TypeScript definitions out of the box.
Responses are fully typed, giving you autocomplete and compile-time validation throughout your application. The types you'll most often need are exported from the package:
import type {
AnyPaperNode,
MetadataFilter,
PaperMetadata,
PaperNodeType,
SearchEvent,
SearchResult,
SearchResultItem,
} from "@paperful/sdk"; | Type | Description |
|---|---|
AnyPaperNode | A node of the paper graph. Checking its type narrows its data. |
PaperNodeType | Every node type, such as "table" or "paragraph_title". |
PaperMetadata | The metadata attached to a paper. |
MetadataFilter | A filter for listing and searching by metadata. |
SearchResult, SearchResultItem | The search response and each of its results. |
SearchEvent, PaperUploadEvent | The events received while searching or uploading. |
The schema of each node type, such as PaperTableNodeSchema, and of its data, such as NodeTableData, are exported as well, along with a class for each error, such as NotFound and ValidationError.
Runtime support
The SDK is designed for modern server-side JavaScript runtimes.
| Runtime | Support |
|---|---|
| Node.js | Supported |
| Bun | Supported |
| TypeScript | Supported |
| Serverless | Supported |
| Browser | Not recommended |
The SDK must be used from backend or server-side environments.