npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pdf2markdown-sdk

v0.1.0

Published

Official JavaScript SDK for pdf2markdown.io API

Readme

pdf2markdown-sdk

Official JavaScript SDK for the pdf2markdown.io API. Convert PDFs and images to markdown with sync or async parsing.

Installation

npm install pdf2markdown-sdk
# or
pnpm add pdf2markdown-sdk
# or
yarn add pdf2markdown-sdk

Quick Start

import { Pdf2Markdown } from "pdf2markdown-sdk";

const client = new Pdf2Markdown({
  apiKey: process.env.PDF2MARKDOWN_API_KEY!,
});

// Sync parse from URL
const res = await client.parse({ input: "https://example.com/doc.pdf" });
console.log(res.data.result.markdown);

// Sync parse from file (Node.js)
import { readFileSync } from "fs";
const buffer = readFileSync("document.pdf");
const res2 = await client.parse({ file: buffer, filename: "document.pdf" });

Sync Parse

Use client.parse() for synchronous conversion. Results return immediately (suitable for smaller documents).

// From URL
const res = await client.parse({ input: "https://example.com/doc.pdf" });

// From file (File, Blob, Buffer, ArrayBuffer)
const res = await client.parse({
  file: fileOrBlobOrBuffer,
  filename: "document.pdf",
});

// From base64
const res = await client.parse({
  base64: "JVBERi0xLjQK...",
  filename: "document.pdf",
});

// Options
const res = await client.parse(
  { input: "https://..." },
  { output: "markdown", page_images: false }
);

Response (sync)

{
  code: "success",
  data: {
    result: { markdown?: string; pages?: ParsePage[] },
    uid: string
  }
}
  • output: "markdown"result.markdown only
  • output: "json"result.pages only
  • output: "all" (default) → both

Async Parse

For larger documents, use async parsing to avoid timeouts:

// Submit task
const { data } = await client.parseAsync({ file: buffer, filename: "large.pdf" });
const taskId = data.task_id;

// Poll until done
const result = await client.waitForTask(taskId, {
  pollIntervalMs: 2000,
  timeoutMs: 120000,
});
console.log(result.result.markdown);

Or manually:

const { data } = await client.parseAsync({ input: "https://..." });
const taskId = data.task_id;

// Check status
const status = await client.taskStatus(taskId);
if (status.status === "completed") {
  const result = await client.taskResult(taskId);
  console.log(result.result.markdown);
}

Configuration

const client = new Pdf2Markdown({
  apiKey: "p2m_live_xxx",
  baseUrl: "https://pdf2markdown.io",  // optional, default
  fetch: customFetch,  // optional, for proxies/retries
});

Supported Formats

  • PDF
  • Images: PNG, JPEG, GIF, WebP, BMP, TIFF

Error Handling

import { Pdf2Markdown, Pdf2MarkdownError } from "pdf2markdown-sdk";

try {
  await client.parse({ input: "https://..." });
} catch (err) {
  if (err instanceof Pdf2MarkdownError) {
    console.error(err.code, err.message, err.status);
  }
}

API Reference

| Method | Description | |--------|-------------| | parse(input, opts?) | Sync parse (file/url/base64) | | parseAsync(input, opts?) | Async submit, returns task_id | | taskStatus(taskId) | Get task status | | taskResult(taskId) | Get result (fetches presigned URL) | | waitForTask(taskId, opts?) | Poll until completed | | tasks.status(taskId) | Alias for taskStatus | | tasks.result(taskId) | Alias for taskResult |

License

See the main pdf2markdown repository.