
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@templatefox/sdk
Advanced tools
Official TemplateFox TypeScript SDK - Generate PDFs from HTML templates
Official TypeScript/Node.js SDK for TemplateFox - Generate PDFs from HTML templates via API.
npm install @templatefox/sdk
Or with yarn:
yarn add @templatefox/sdk
import { Configuration, PDFApi, CreatePdfRequest } from '@templatefox/sdk';
// Initialize the client
const config = new Configuration({
apiKey: 'your-api-key',
});
const api = new PDFApi(config);
// Generate a PDF
async function generatePdf() {
const response = await api.createPdf({
templateId: 'YOUR_TEMPLATE_ID',
data: {
name: 'John Doe',
invoiceNumber: 'INV-001',
totalAmount: 150.00,
},
});
console.log('PDF URL:', response.url);
console.log('Credits remaining:', response.creditsRemaining);
}
generatePdf();
// Generate PDF and get URL
const response = await api.createPdf({
templateId: 'TEMPLATE_ID',
data: { name: 'John Doe' },
exportType: 'url', // 'url' or 'binary'
expiration: 86400, // URL expiration in seconds (default: 24h)
filename: 'invoice-001', // Custom filename
});
import { TemplatesApi } from '@templatefox/sdk';
const templatesApi = new TemplatesApi(config);
// List all templates
const templates = await templatesApi.listTemplates();
// Get template fields
const fields = await templatesApi.getTemplateFields({ templateId: 'TEMPLATE_ID' });
import { AccountApi } from '@templatefox/sdk';
const accountApi = new AccountApi(config);
// Get account info
const account = await accountApi.getAccount();
console.log('Credits:', account.credits);
// List transactions
const transactions = await accountApi.listTransactions({ limit: 100, offset: 0 });
import { IntegrationsApi } from '@templatefox/sdk';
const integrationsApi = new IntegrationsApi(config);
// Save S3 configuration
await integrationsApi.saveS3Config({
s3ConfigRequest: {
endpointUrl: 'https://s3.amazonaws.com',
accessKeyId: 'AKIAIOSFODNN7EXAMPLE',
secretAccessKey: 'your-secret-key',
bucketName: 'my-pdf-bucket',
defaultPrefix: 'generated/pdfs/',
}
});
// Test connection
const test = await integrationsApi.testS3Connection();
console.log('Connection:', test.success ? 'OK' : 'Failed');
const config = new Configuration({
basePath: 'https://api.templatefox.com', // Default API URL
apiKey: 'your-api-key',
});
// Or use environment variable
const config = new Configuration({
apiKey: process.env.TEMPLATEFOX_API_KEY,
});
try {
const response = await api.createPdf({ /* ... */ });
} catch (error) {
if (error.status === 402) {
console.error('Insufficient credits');
} else if (error.status === 403) {
console.error('Access denied - check your API key');
} else if (error.status === 404) {
console.error('Template not found');
} else {
console.error('Error:', error.message);
}
}
MIT License - see LICENSE for details.
FAQs
Official TemplateFox TypeScript SDK - Generate PDFs from HTML templates
The npm package @templatefox/sdk receives a total of 316 weekly downloads. As such, @templatefox/sdk popularity was classified as not popular.
We found that @templatefox/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.