Registry / http-networking / launchdarkly-api-typescript

launchdarkly-api-typescript

JSON →
library22.0.0jsnpmunverified

This package provides a TypeScript/JavaScript client for interacting with the LaunchDarkly REST API, automatically generated from their OpenAPI specification. It is built on `axios` and supports both Node.js and browser environments, with compatibility for ES5/ES6 and CommonJS/ES6 module systems. The current stable version is `22.0.0`, with frequent releases mirroring updates to the LaunchDarkly API. This client is specifically designed for custom integrations, data export, and automating feature flag workflows, such as programmatic flag management. It is crucial to note that this client library should *not* be used for integrating feature flags directly into web or mobile applications; dedicated SDKs are available for that purpose. It serves as a programmatic interface for administrative tasks rather than a runtime feature flag evaluation tool.

npm install launchdarkly-api-typescript
INSTALL
IMPORT
SIG · LAUNCHDARKLY-API-T
L
launchdarkly-api-typescript
http-networkingjavascriptv22.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Configuration
import { Configuration } from 'launchdarkly-api-typescript';
const Configuration = require('launchdarkly-api-typescript').Configuration;
Used to configure the API client with base paths, API keys, and other settings. The CommonJS require pattern is generally discouraged in modern TypeScript/JavaScript projects.
AIConfigsApi
import { AIConfigsApi } from 'launchdarkly-api-typescript';
import AIConfigsApi from 'launchdarkly-api-typescript';
API classes (e.g., `AIConfigsApi`, `ProjectsApi`, `FeatureFlagsApi`) are named exports. Attempting to use a default import will result in a runtime error.
FlagsApi
import { FlagsApi } from 'launchdarkly-api-typescript';
import { FlagsApi } from 'launchdarkly-api-typescript/dist/api';
All top-level API client classes and types are exported directly from the main package entry point. Deep imports are not necessary and can break with future internal refactorings.

This quickstart demonstrates how to initialize the LaunchDarkly API client using an access token and retrieve a list of feature flags for a specified project. It highlights the use of `Configuration` and an API-specific class like `FlagsApi`.

import { Configuration, FlagsApi } from 'launchdarkly-api-typescript'; const LAUNCHDARKLY_API_KEY = process.env.LAUNCHDARKLY_API_KEY ?? ''; const PROJECT_KEY = 'my-project'; // Replace with your project key if (!LAUNCHDARKLY_API_KEY) { console.error('LAUNCHDARKLY_API_KEY environment variable is not set.'); process.exit(1); } async function listFlagsForProject() { const configuration = new Configuration({ accessToken: LAUNCHDARKLY_API_KEY, basePath: 'https://app.launchdarkly.com' }); const flagsApi = new FlagsApi(configuration); try { console.log(`Fetching feature flags for project: ${PROJECT_KEY}...`); const response = await flagsApi.getFeatureFlags({ projectKey: PROJECT_KEY }); console.log(`Found ${response.items.length} feature flags.`); if (response.items.length > 0) { console.log('First flag key:', response.items[0].key); console.log('First flag name:', response.items[0].name); } } catch (error) { console.error('Error fetching feature flags:', error.response?.data || error.message); } } listFlagsForProject();
Debug
Known issues
gotchaThis client library is exclusively for programmatic interaction with the LaunchDarkly REST API (e.g., custom integrations, automation). It must NOT be used to integrate feature flags into client-side (web/mobile) or server-side applications for flag evaluation. For in-application feature flagging, use the official LaunchDarkly SDKs.
fix
Use the appropriate LaunchDarkly SDK (e.g., `launchdarkly-node-server-sdk`, `launchdarkly-js-client-sdk`) for in-application feature flag evaluation.
affects: >=1.0.0
breakingThe client library updates frequently to align with the latest version of the LaunchDarkly REST API. Major version bumps (`vX.0.0`) typically indicate significant API changes, which may include new endpoints, modified request/response bodies, or removal of deprecated features, potentially breaking existing integrations.
fix
Always review the release notes for new major versions (e.g., v20.0.0, v21.0.0, v22.0.0) before upgrading. Ensure your access token's API version setting is compatible with the client library version in use.
affects: >=1.0.0
gotchaAPI access tokens are sensitive credentials. When using this client, ensure API keys are stored securely (e.g., environment variables, secret management services) and never hardcoded or exposed in client-side code.
fix
Retrieve `LAUNCHDARKLY_API_KEY` from secure environment variables or a secrets manager. Avoid committing API keys to version control.
affects: >=1.0.0
gotchaThe API client is generated using OpenAPI tools, which means the structure of request bodies and response objects strictly adheres to the OpenAPI specification. Mismatches in property names, types, or required fields will lead to validation errors or unexpected behavior.
fix
Refer to the generated client's JSDoc/TypeScript types or the LaunchDarkly API documentation for the exact structure of request and response payloads. Use TypeScript to leverage type checking during development.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'data')
An API request failed, and the error object thrown by axios does not have the expected structure for direct access to `error.response.data`, or `error.response` is `undefined`.
fix
When handling API errors, check if `error.response` and `error.response.data` exist before accessing them, especially when expecting specific error messages from the server. For example: `error.response?.data || error.message`.
Error: Request failed with status code 401
The provided API access token is missing, invalid, or does not have sufficient permissions for the requested operation.
fix
Verify that your `LAUNCHDARKLY_API_KEY` is correctly set and is a valid access token. Check the token's permissions in the LaunchDarkly UI to ensure it has the necessary scopes for the API endpoints you are calling.
TypeError: __importDefault is not a function
Attempting to use ES module imports (`import ... from 'pkg'`) in a CommonJS environment without proper transpilation (e.g., via Babel or TypeScript targeting `commonjs` but configured incorrectly).
fix
Ensure your `tsconfig.json` `module` option is set correctly for your target environment (e.g., `"commonjs"` for Node.js projects, `"esnext"` or `"es2020"` for browser environments with bundlers). If using CommonJS, use `const { ... } = require('pkg');` syntax.
Upgrade
Version history
22.0.0latest on npm
Audit
Dependencies
axiosrequiredUsed as the underlying HTTP client for making API requests.
Agent activity
2 hits · last 30 days
node
2
Resources
launchdarkly-api-typescript — npm install launchdarkly-api-typescript · libregistry