Integrations
TypeScript
Use the SafeURL TypeScript SDK
The TypeScript SDK is generated from the OpenAPI spec and lives in the ts/ folder of the gnoverse/safeurl-sdk repository.
Installation
npm install @gnoverse/safeurl-ts
# or
bun add @gnoverse/safeurl-tsQuick example
import { createClient } from "@gnoverse/safeurl-ts";
const client = createClient({
baseUrl: "https://api.safeurl.ai",
headers: {
Authorization: `Bearer ${process.env.SAFEURL_API_KEY}`,
},
});
// Submit a scan
const { data, error } = await client.scans.create({
url: "https://example.com",
});
if (error) {
console.error("Scan failed:", error);
process.exit(1);
}
console.log("Scan submitted:", data.id);
// Get scan results
const { data: scan } = await client.scans.getById({
id: data.id,
});
console.log("Scan result:", scan);Batch scan
const { data: batch } = await client.scans.createBatch({
urls: ["https://example.com", "https://suspicious-site.xyz"],
});
console.log("Batch created:", batch.batchId);Regenerating the SDK
The SDK is generated from the live OpenAPI spec using @hey-api/openapi-ts. With the API running locally:
bun run codegen:ts-sdk