Skip to main content
Browse the docs

Batteries included

JavaScript SDK

A typed client over the REST API — retries, polling, and webhook verification handled for you. Back to API reference.

Install

npm install @searchlayerpdf/sdk

Process a PDF

One call creates the job, uploads your file, and waits for the upgraded result.

import { Client } from '@searchlayerpdf/sdk';
import { readFileSync } from 'node:fs';

const client = new Client({ apiKey: process.env.SLP_API_KEY });

const result = await client.process({
  source: readFileSync('scan.pdf'),   // Buffer, Blob, or a URL
  quality: 'economy',                  // economy | quality
  privacy: 'private',                  // open | private
  waitForCompletion: true,             // poll until done
});

console.log(result.status);            // "done"
const { download_url } = await client.jobs.getResult(result.job_id);

Jobs resource

await client.jobs.create({ quality: 'quality', privacy: 'private', max_cost_cents: 500 });
await client.jobs.get(jobId);            // status, tier, pages, cost
await client.jobs.getResult(jobId);      // signed download URL
await client.jobs.getDiagnostics(jobId); // per-page Retrievability Scores
await client.jobs.delete(jobId);         // remove job + documents
await client.jobs.waitForCompletion(jobId);

Manage keys with client.apiKeys.create(), .list(), and .delete(id).

Webhooks & errors

Verify webhook signatures (HMAC-SHA256) before trusting a payload:

import { verifyWebhook } from '@searchlayerpdf/sdk';

const ok = verifyWebhook({
  payload: rawBody,
  signature: req.headers['x-slp-signature'],
  secret: process.env.SLP_WEBHOOK_SECRET,
});

Errors throw typed classes you can branch on: AuthError, NotFoundError, RateLimitError, TimeoutError (all extend SlpError). Requests retry automatically on 429 and 5xx with exponential backoff.

Command line

No install needed — npx searchlayerpdf. Reads SLP_API_KEY from the environment or ~/.searchlayerpdf/config.json.

npx searchlayerpdf process scan.pdf --quality quality --privacy private   # submit + poll
npx searchlayerpdf jobs list                     # list recent jobs
npx searchlayerpdf jobs get <id>                 # inspect one job
npx searchlayerpdf keys create "my laptop"       # mint an API key
npx searchlayerpdf doctor                        # check connectivity + auth