SDK
@xhrdev/sdk gives you TypeScript types for the on-prem API — the request and response shapes for every endpoint, generated from the same OpenAPI spec the docs are built from.
Types, not a client
It deliberately isn't an HTTP client. You're calling your own container over plain HTTP with no auth scheme to wrap, so there's nothing meaningful for a client wrapper to do. Use fetch, axios, undici — whatever you already have — and let the SDK type it. See Using HTTP clients.
Installation
npm install --save-dev @xhrdev/sdkTypes only, so it belongs in devDependencies.
Typed requests and responses
import type {
AkamaiSolveRequest,
AkamaiSolveResponse,
AkamaiQueueMetrics,
DatadomeSolveRequest,
DatadomeSolveResponse,
} from '@xhrdev/sdk';Wrap your own call however you like:
import type { DatadomeSolveRequest } from '@xhrdev/sdk';
const SOLVER = process.env.SOLVER_URL ?? 'http://localhost:3000';
async function solveDataDome(body: DatadomeSolveRequest) {
const res = await fetch(`${SOLVER}/dd/solve`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify(body),
signal: AbortSignal.timeout(30_000),
});
if (!res.ok) {
throw new Error(`solver returned HTTP ${res.status}: ${await res.text()}`);
}
// A prepared submission — send it yourself from your own IP.
return res.json();
}The same for Akamai:
import type { AkamaiSolveRequest, AkamaiSolveResponse } from '@xhrdev/sdk';
async function solveAkamai(
body: AkamaiSolveRequest
): Promise<AkamaiSolveResponse> {
const res = await fetch(`${SOLVER}/akamai/solve`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify(body),
});
return res.json();
}Health and queue depth
import type { AkamaiQueueMetrics } from '@xhrdev/sdk';
const metrics: AkamaiQueueMetrics = await (
await fetch(`${SOLVER}/akamai/queue-metrics`)
).json();
if (metrics.queued > 16) {
// back off, or scale out another container
}Raw OpenAPI types
Every path, operation, and component is reachable if you need something the named exports don't cover:
import { sdk } from '@xhrdev/sdk';
type ApiPaths = sdk.paths;
type ApiOperations = sdk.operations;
type ApiComponents = sdk.components;
type SolveOperation = sdk.operations['postAkamaiSolve'];
type ProfileSnapshot = sdk.components['schemas']['ProfileSnapshot'];The spec itself
import { openApiSpec, getOpenApiSpec } from '@xhrdev/sdk';
console.log(openApiSpec); // the spec as a YAML stringYou can also download openapi.yml directly or browse it interactively — useful for generating a client in a language the SDK doesn't cover.
Covered endpoints
| Endpoint | Types |
|---|---|
GET /hc | — |
GET /akamai/queue-metrics | AkamaiQueueMetrics |
POST /akamai/solve | AkamaiSolveRequest, AkamaiSolveResponse |
POST /dd/solve | DatadomeSolveRequest, DatadomeSolveResponse |
The Akamai WebSocket session (/akamai/session) isn't in the spec — OpenAPI 3.0 can't express a WebSocket protocol. Its message schemas are documented in the Akamai API reference.