swap3d-js
Developer Toolshttps://github.com/swap3d/swap3d-js
Official TypeScript and JavaScript SDK for the Swap3D developer API.
About this project
Swap3D JavaScript SDK is the official TypeScript/JavaScript client for the Swap3D developer API, enabling 3D model conversion and management. It provides a programmatic interface to convert 3D models between formats, check conversion status, and download results. The SDK is designed for Node.js 18+ and modern runtimes with Fetch API support, including Blob and FormData. Key features include creating conversion jobs, monitoring job status with progress callbacks, downloading converted models, and retrieving supported formats and usage metrics. The SDK handles transient errors with automatic retries for safe GET requests and provides structured error responses with machine-readable details. It enforces type safety through OpenAPI-generated types and includes built-in support for abort signals. To get started, install the package via npm (`npm install @swap3d/sdk`) and initialize the client with an API key from the Swap3D dashboard. The basic workflow involves uploading a source file, creating a conversion job, waiting for completion, and downloading the result. The SDK emphasizes security by warning against exposing API keys in browser code or source control. Development setup includes standard npm commands for testing and packaging.
This is a GitHub repository (source code), not a hosted HTTP API endpoint.
From the docs
Snippets taken from the repository README when available.
npm install @swap3d/sdkimport { readFile, writeFile } from "node:fs/promises";
import { Swap3DClient } from "@swap3d/sdk";
const client = new Swap3DClient({
apiKey: process.env.SWAP3D_API_KEY,
});
const source = await readFile("./model.obj");
const job = await client.createConversion({
file: new Blob([source]),
fileName: "model.obj",
targetFormat: "glb",
});
const status = await client.waitForConversion(job.jobId, {
onStatus: ({ status }) => console.log(status),
});
if (status.status === "completed" && status.result) {
const response = await client.download(status.result.downloadUrl);
const output = new Uint8Array(await response.arrayBuffer());
await writeFile("./model.glb", output);
}