Skip to main content
The BlueBubbles SDK is written entirely in TypeScript and ships with complete type definitions. Every service method is typed end-to-end — from request parameters to response shapes — so your editor can autocomplete fields, flag mismatches at compile time, and help you navigate the API without leaving your IDE. This page covers the key types and interfaces you will interact with when building on top of the SDK.

Exported symbols

The package root (bluebubbles-sdk) re-exports everything you need. Import only what your code uses to keep bundles small.

The OpenAPIConfig type

OpenAPIConfig controls how the SDK authenticates and constructs requests. You pass a Partial<OpenAPIConfig> to the BlueBubblesClient constructor — any fields you omit fall back to their defaults.

Field reference

Type: string | Default: "http://localhost"The root URL of your BlueBubbles Server, without a trailing slash. Include the port if your server is not on the default HTTP/HTTPS port.
Type: string | Default: "1.0.0"The API version to target. You do not normally need to change this unless you are explicitly pinning to a specific server version.
Type: boolean | Default: falseWhen true, the underlying fetch call includes credentials (cookies) for cross-origin requests. Set this to true only if your server and client are on different origins and you are using cookie-based session management.
Type: 'include' | 'omit' | 'same-origin' | Default: 'include'Maps directly to the credentials option of the Fetch API. Controls whether cookies and HTTP authentication headers are sent with requests. 'include' sends credentials for both same-origin and cross-origin requests.
Type: string | ((options: ApiRequestOptions) => Promise<string>) | undefinedA static bearer token string, or an async resolver function that returns a token. Use the function form when your token may expire and needs to be refreshed per-request.
Type: string | ((options: ApiRequestOptions) => Promise<string>) | undefinedCredentials for HTTP Basic authentication. BlueBubbles Server uses PASSWORD to validate requests. Like TOKEN, both fields accept a static string or an async resolver.
Type: Record<string, string> | ((options: ApiRequestOptions) => Promise<Record<string, string>>) | undefinedAdditional headers merged into every request. Useful for custom tracing headers, API gateways, or proxies that require specific headers.
Type: ((path: string) => string) | undefinedA function that encodes dynamic path segments before they are inserted into the URL. By default the SDK uses encodeURIComponent. Override this if your server expects a different encoding scheme.

Typed usage patterns

Strongly typed service calls

Every service method accepts a typed parameter object and returns a typed CancelablePromise. TypeScript will catch incorrect field names and type mismatches before you run your code.

Using CancelablePromise<T> as a type annotation

When you store a pending request in a variable (for example, so you can cancel it later), annotate it with CancelablePromise<T> to preserve type safety.

Narrowing ApiError in catch blocks

TypeScript’s catch clause types the caught value as unknown. Import and check ApiError before accessing its properties.

Extending the HTTP layer with BaseHttpRequest

BaseHttpRequest is the abstract class that sits between the service layer and the network. The SDK ships with FetchHttpRequest, which uses the native Fetch API. You can replace it with any implementation — for example, to use axios, to add retry logic, or to mock requests in tests.
1

Extend BaseHttpRequest

Your class must implement a single abstract method: request<T>(options: ApiRequestOptions): CancelablePromise<T>.
2

Pass it to BlueBubblesClient

The second argument to BlueBubblesClient is the constructor of your BaseHttpRequest subclass.
This pattern is especially useful for testing. Create a MockHttpRequest that returns fixture data from a map of (method, url) → response, then pass it to BlueBubblesClient in your test setup. Your service logic is exercised without any real network traffic.

Tree-shaking and selective imports

The SDK uses named exports throughout — there is no default export and no barrel file that forces you to load everything. Modern bundlers (Vite, esbuild, Rollup, webpack 5) will tree-shake unused service classes and utilities automatically. Import only what your module actually uses:
Type-only imports (import type) are always safe: they are erased entirely at compile time and add zero bytes to your bundle.
If you are using "moduleResolution": "bundler" or "moduleResolution": "node16" in your tsconfig.json, the SDK’s package exports map ensures that TypeScript resolves the correct type declaration files automatically — no typeRoots or manual paths configuration is needed.