@tongorender/sdk
v0.1.0
Published
Official TypeScript SDK for the TongoRender API — HTML to PDF, Image & Screenshot
Maintainers
Readme
@tongorender/sdk
Official TypeScript SDK for the TongoRender API — convert HTML to PDF, images, and screenshots.
Install
npm install @tongorender/sdkQuick Start
import { TongoClient } from '@tongorender/sdk';
const tongo = new TongoClient('your-api-key');
// HTML to PDF
const job = await tongo.pdf.render({
html: '<h1>Hello World</h1>',
format: 'A4',
});
// HTML to Image
const image = await tongo.image.render({
html: '<h1>Hello World</h1>',
format: 'png',
});
// Screenshot a URL
const screenshot = await tongo.screenshot.render({
url: 'https://example.com',
format: 'png',
fullPage: true,
});Configuration
const tongo = new TongoClient({
apiKey: 'your-api-key',
baseUrl: 'https://api.tongo.io', // optional
timeout: 30000, // optional, ms
});Resources
| Resource | Description |
|----------|-------------|
| tongo.pdf | HTML to PDF rendering |
| tongo.image | HTML to image rendering (PNG, JPEG, WebP) |
| tongo.screenshot | URL screenshots |
| tongo.render | Render job management |
| tongo.batch | Batch rendering |
| tongo.templates | Template management |
| tongo.keys | API key management |
| tongo.usage | Usage statistics |
| tongo.account | Account info |
Error Handling
import { TongoApiError, TongoTimeoutError, TongoNetworkError } from '@tongorender/sdk';
try {
await tongo.pdf.render({ html: '<h1>Hello</h1>' });
} catch (err) {
if (err instanceof TongoApiError) {
console.error(err.status, err.code, err.message);
}
}Requirements
- Node.js >= 18.0.0
License
MIT
