Paperful Icon
Paperfuldocs

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.

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_..."
});
Keep your API key on the server. Do not expose it in client-side applications or commit it to source control.

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";
TypeDescription
AnyPaperNodeA node of the paper graph. Checking its type narrows its data.
PaperNodeTypeEvery node type, such as "table" or "paragraph_title".
PaperMetadataThe metadata attached to a paper.
MetadataFilterA filter for listing and searching by metadata.
SearchResult, SearchResultItemThe search response and each of its results.
SearchEvent, PaperUploadEventThe 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.

RuntimeSupport
Node.jsSupported
BunSupported
TypeScriptSupported
ServerlessSupported
BrowserNot recommended

The SDK must be used from backend or server-side environments.

Guides

On this page