@enconvert/node-sdk
v0.0.1
Published
JavaScript / TypeScript SDK for the Enconvert file conversion API
Maintainers
Readme
enconvert
JavaScript / TypeScript SDK for the Enconvert file conversion API.
Convert URLs to PDFs, capture screenshots, transform images, and convert documents — all with a single API call. Node 18+.
Install
npm install @enconvert/node-sdkQuick Start
import { Enconvert } from "@enconvert/node-sdk";
const client = new Enconvert({ apiKey: "sk_..." });URL to PDF
const result = await client.convertUrlToPdf("https://example.com", {
saveTo: "page.pdf",
});
console.log(result.presignedUrl);URL to Screenshot
const result = await client.convertUrlToScreenshot("https://example.com", {
viewportWidth: 1440,
saveTo: "screenshot.png",
});URL to Markdown
Extract clean GitHub-Flavored Markdown from any URL — strips nav/footer/ads/scripts, keeps the main article content, and adds YAML frontmatter (title, description, url, links, images).
const result = await client.convertUrlToMarkdown("https://example.com/article", {
saveTo: "article.md",
});Image Conversion
const result = await client.convertImage("photo.heic", {
outputFormat: "webp",
saveTo: "photo.webp",
});Supported formats: jpeg, png, svg, heic, webp
Document Conversion
await client.convertDocument("report.docx", { saveTo: "report.pdf" });
await client.convertDocument("data.json", { outputFormat: "yaml", saveTo: "data.yaml" });Supported inputs: doc/docx, xls/xlsx, ppt/pptx, html, odt, ods, odp, epub, markdown, csv, json, xml, yaml, toml
Job Status (async polling)
const status = await client.getJobStatus("job_abc123");
if (status.status === "success") {
console.log(status.presignedUrl);
}PDF Options
const result = await client.convertUrlToPdf("https://example.com", {
pdfOptions: {
pageSize: "A4",
orientation: "landscape",
margins: { top: 10, bottom: 10, left: 15, right: 15 },
},
saveTo: "report.pdf",
});Error Handling
import { Enconvert, AuthenticationError, RateLimitError, APIError } from "@enconvert/node-sdk";
try {
await client.convertUrlToPdf("https://example.com");
} catch (e) {
if (e instanceof AuthenticationError) console.error("Invalid API key");
else if (e instanceof RateLimitError) console.error("Too many requests — slow down");
else if (e instanceof APIError) console.error(`API error [${e.statusCode}]: ${e.message}`);
else throw e;
}Configuration
const client = new Enconvert({
apiKey: "sk_...",
timeout: 300_000, // ms, default
});Get an API Key
Sign up at enconvert.com to get your API key.
License
MIT
