parsejet
v0.1.2
Published
Official ParseJet SDK for Node.js/Bun/Deno - Parse URLs, PDFs, YouTube transcripts, web pages, and images with ease
Downloads
323
Maintainers
Readme
ParseJet SDK
The official ParseJet SDK for Node.js, Bun, and Deno. Extract text from URLs, PDFs, YouTube videos, web pages, and images with a single API.
Installation
# npm
npm install parsejet
# pnpm
pnpm add parsejet
# yarn
yarn add parsejet
# bun
bun add parsejetRequirements: Node.js 18+ (uses native fetch).
Quick Start
import { ParseJet } from "parsejet";
const client = new ParseJet({ apiKey: "pj_YOUR_KEY" });
const result = await client.parse.url("https://example.com");
console.log(result.title);
console.log(result.text);Authentication
Pass your API key directly or set it as an environment variable:
// Option 1: Pass directly
const client = new ParseJet({ apiKey: "pj_YOUR_KEY" });
// Option 2: Environment variable (PARSEJET_API_KEY)
const client = new ParseJet();API Reference
All parse methods return a ParseResult:
type ParseResult = {
text: string;
title: string;
source_type: string;
metadata: Record<string, any>;
};client.parse.url(url, options?)
Parse any URL. ParseJet auto-detects the content type (web page, PDF, YouTube, etc.).
const result = await client.parse.url("https://example.com/report.pdf");
console.log(result.text);
console.log(result.source_type); // "pdf", "webpage", "youtube", etc.With markdown output:
const result = await client.parse.url("https://example.com/article", {
outputFormat: "markdown",
});client.parse.file(buffer, filename, options?)
Parse a file from a Buffer or Uint8Array.
import fs from "fs";
const buffer = fs.readFileSync("report.pdf");
const result = await client.parse.file(buffer, "report.pdf");
console.log(result.text);client.parse.filePath(path, options?)
Parse a file directly from a local path.
const result = await client.parse.filePath("/path/to/report.pdf");
console.log(result.text);client.parse.youtube(url, options?)
Extract a YouTube video transcript.
const result = await client.parse.youtube(
"https://youtube.com/watch?v=dQw4w9WgXcQ",
{ language: "en" }
);
console.log(result.text);client.parse.webpage(url, options?)
Parse a web page and extract its content.
const result = await client.parse.webpage("https://example.com/article");
console.log(result.title);
console.log(result.text);client.parse.ocr(buffer, filename, options?)
Perform OCR on an image.
import fs from "fs";
const image = fs.readFileSync("screenshot.png");
const result = await client.parse.ocr(image, "screenshot.png");
console.log(result.text);Options
ParseOptions
Available on all methods:
| Option | Type | Description |
| -------------- | ------------------------ | ---------------------- |
| outputFormat | "text" | "markdown" | Output format |
YouTubeOptions
Additional options for client.parse.youtube():
| Option | Type | Description |
| ---------- | -------- | ---------------------------------- |
| language | string | Preferred transcript language code |
Error Handling
The SDK throws ParseJetError for API errors, which includes the HTTP status code and the error body.
import { ParseJet, ParseJetError } from "parsejet";
const client = new ParseJet();
try {
const result = await client.parse.url("https://example.com");
} catch (error) {
if (error instanceof ParseJetError) {
console.error(`API error ${error.status}: ${error.message}`);
console.error(error.body);
} else {
throw error;
}
}Configuration
const client = new ParseJet({
apiKey: "pj_YOUR_KEY", // API key (or set PARSEJET_API_KEY env var)
baseUrl: "https://api.parsejet.com", // Custom base URL (optional)
});Environment Variables
| Variable | Description |
| ------------------ | ------------- |
| PARSEJET_API_KEY | Your API key |
License
MIT
