Exported symbols
The package root (bluebubbles-sdk) re-exports everything you need. Import only what your code uses to keep bundles small.
| Export | Kind | Description |
|---|---|---|
BlueBubblesClient | class | The main client that exposes all service namespaces. |
ApiError | class | Error thrown when a request receives a non-2xx response. |
BaseHttpRequest | abstract class | Base class you extend to provide a custom HTTP transport. |
CancelablePromise<T> | class | A Promise<T> with an added cancel() method. |
CancelError | class | Thrown by CancelablePromise when cancel() is called. |
OpenAPI | const | The mutable default config object used when no config is passed. |
OpenAPIConfig | type | The shape of the configuration object accepted by BlueBubblesClient. |
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
BASE — server base URL
BASE — server base URL
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.VERSION — API version string
VERSION — API version string
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.WITH_CREDENTIALS — send cookies cross-origin
WITH_CREDENTIALS — send cookies cross-origin
CREDENTIALS — fetch credentials mode
CREDENTIALS — fetch credentials mode
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.TOKEN — bearer token auth
TOKEN — bearer token auth
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.USERNAME and PASSWORD — basic auth
USERNAME and PASSWORD — basic auth
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.HEADERS — global request headers
HEADERS — global request headers
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.ENCODE_PATH — custom path segment encoding
ENCODE_PATH — custom path segment encoding
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 typedCancelablePromise. 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.
Extend BaseHttpRequest
Your class must implement a single abstract method:
request<T>(options: ApiRequestOptions): CancelablePromise<T>.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: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.