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

@secretpdf/sdk

v1.0.4

Published

TypeScript/JavaScript SDK for Secret PDF API - Generate PDFs from HTML templates in one api call.

Downloads

443

Readme

Secret PDF SDK

A TypeScript/JavaScript SDK for the Secret PDF API. Generate beautiful PDFs from HTML templates with AI assistance.

npm version License: MIT

Installation

npm install @secretpdf/sdk

Or with yarn:

yarn add @secretpdf/sdk

Or with pnpm:

pnpm add @secretpdf/sdk

Quick Start

import { SecretPDFClient } from '@secretpdf/sdk';

// Initialize the client
const client = new SecretPDFClient({
  apiKey: 'your-api-key-here'
});

// Generate a PDF from a template
const result = await client.generate({
  templateId: 'your-template-id',
  returnFile: true,
  data: { name: 'World' }
});

console.log('PDF generated:', result);
// result.data contains the Base64 raw data of the PDF

Usage

Authentication

The SDK supports multiple authentication methods:

API Key Authentication

const client = new SecretPDFClient({
  apiKey: 'your-api-key-here'
});

Document Generation

Generate PDFs from templates:

// Generate from a template
const pdfResult = await client.generate({
  templateId: 'template-123',
  data: {
    customerName: 'John Doe',
    amount: '$250.00'
  }
});


// Use sandbox mode for testing (adds watermark, no credit charge)
const sandboxPdf = await client.generate({
  templateId: 'template-123',
  data: {},
  sandbox: true
});

Template Management

Manage reusable templates:

// Create a template
const newTemplate = await client.createTemplate({
  templateContent: '<html><body><h1>{{title}}</h1><p>{{content}}</p></body></html>',
  templateName: 'Invoice Template',
  templateSize: 'A4'
});

// List all templates
const templates = await client.listTemplates();

// Get a specific template
const template = await client.getTemplate('template-123');

// Update a template
const updated = await client.updateTemplate({
  templateId: 'template-123',
  templateName: 'Updated Invoice Template',
  templateContent: '<html><body>Updated content</body></html>'
});

// Delete a template
await client.deleteTemplate('template-123');

AI-Powered Template Generation

Generate templates from PDF files or text prompts:

// Generate template from a PDF file
const pdfFile = new Blob([pdfData], { type: 'application/pdf' });
const templateFromPdf = await client.generateTemplateFromPdf(pdfFile);

// Generate template from a text prompt using AI
const templateFromPrompt = await client.generateTemplateFromPrompt({
  prompt: 'Create a professional invoice template with company header, itemized table, and total section',
  params: { 
    companyName: '', 
    customerName: '', 
    items: [], 
    total: '' 
  },
  templateName: 'AI Invoice Template'
});

Custom Fetch Implementation

import fetch from 'node-fetch';

const client = new SecretPDFClient({
  apiKey: 'your-api-key',
  fetchApi: fetch as any
});

TypeScript Support

This SDK is written in TypeScript and includes full type definitions. All methods and parameters are fully typed.

import { SecretPDFClient } from '@secretpdf/sdk';

const client = new SecretPDFClient({ apiKey: 'key' });

// All parameters are type-checked
const result = await client.generate({
  templateId: 'template-123',
  data: { name: 'John' }  // data is typed as Record<string, any>
});

// Response types are also fully typed
console.log(result.data?.url); // TypeScript knows the structure

Error Handling

try {
  const result = await client.generate({
    templateId: 'template-123',
    data: {}
  });
  console.log('Success:', result);
} catch (error) {
  if (error instanceof Response) {
    const errorData = await error.json();
    console.error('API Error:', errorData);
  } else {
    console.error('Network Error:', error);
  }
}

License

MIT

Support

For issues, questions, or contributions, please visit:

  • GitHub: https://github.com/SecretPDF/secretpdf-js-sdk
  • Documentation: https://docs.secretpdf.io

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.