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-typescriptVerified import paths — ran on the pinned version, not inferred.
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`.
Use the appropriate LaunchDarkly SDK (e.g., `launchdarkly-node-server-sdk`, `launchdarkly-js-client-sdk`) for in-application feature flag evaluation.
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.
Retrieve `LAUNCHDARKLY_API_KEY` from secure environment variables or a secrets manager. Avoid committing API keys to version control.
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.
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`.
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.
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.