Install & Compatibility
Where this runs
tested against v22.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 11.936s · 83.3MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 4.9s · import 11.268s · 83MB
82MB installed
● package 82MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Configuration
✓ import launchdarkly_api
config = launchdarkly_api.Configuration(...)
The Configuration class is part of the top-level `launchdarkly_api` module.
ApiClient
✓ import launchdarkly_api
api_client = launchdarkly_api.ApiClient(config)
The main API client is accessed directly from the `launchdarkly_api` module.
ProjectsApi
✓ import launchdarkly_api
projects_api = launchdarkly_api.ProjectsApi(api_client)
Specific API groups (e.g., Projects, Flags, Users) are classes within the `launchdarkly_api` module, initialized with an `ApiClient` instance.
ApiException
✓ from launchdarkly_api.rest import ApiException
Exceptions, such as API errors, are typically found in the `launchdarkly_api.rest` submodule.
This quickstart demonstrates how to initialize the LaunchDarkly API client, authenticate using an API key from an environment variable (`LAUNCHDARKLY_API_KEY`), and make a simple call to list all projects in your LaunchDarkly organization. It includes basic error handling for common API issues.
import os
import launchdarkly_api
from launchdarkly_api.rest import ApiException
# Configure API key authorization: ApiKey
configuration = launchdarkly_api.Configuration(
host="https://app.launchdarkly.com"
)
# Your LaunchDarkly API Key (NOT an SDK key)
configuration.api_key['ApiKey'] = os.environ.get('LAUNCHDARKLY_API_KEY', '')
# Create an instance of the API client
try:
with launchdarkly_api.ApiClient(configuration) as api_client:
# Create an instance of the Projects API class
api_instance = launchdarkly_api.ProjectsApi(api_client)
try:
# List all projects
projects = api_instance.get_projects()
if projects and projects.items:
print(f"Successfully retrieved {len(projects.items)} project(s):")
for project in projects.items:
print(f"- {project.name} (Key: {project.key})")
else:
print("No projects found or API key may be invalid/lack permissions.")
except ApiException as e:
print(f"Exception when calling ProjectsApi->get_projects: {e}")
if e.status == 401:
print("Error 401: Unauthorized. Check your LAUNCHDARKLY_API_KEY and its permissions.")
elif e.status == 403:
print("Error 403: Forbidden. Your API key might not have permissions to list projects.")
except ValueError as e:
print(f"Error initializing API client: {e}. Ensure LAUNCHDARKLY_API_KEY is set.")
Debug
Known issues
breakingThe `launchdarkly-api` client library undergoes frequent major version increments, typically indicating breaking changes in the underlying LaunchDarkly REST API. Always pin your dependency version (`launchdarkly-api==X.Y.Z`) and thoroughly review the changelog for migration instructions between versions.fixPin your `launchdarkly-api` dependency version in your `requirements.txt` or `pyproject.toml` and review the changelog when upgrading.
affects: All versions with major increments (e.g., v17.x.x to v18.x.x, v21.x.x to v22.x.x)
gotchaThis `launchdarkly-api` client library is designed for programmatic interaction with the LaunchDarkly REST API (e.g., automation, data export, managing flag configurations). It is *not* for evaluating feature flags within your application. For feature flag evaluation, use the appropriate LaunchDarkly SDK (e.g., `launchdarkly-server-sdk` for Python applications).fixFor feature flag evaluations, install and use `launchdarkly-server-sdk` (or other platform-specific SDKs). For REST API interactions, use `launchdarkly-api`.
affects: All versions
gotchaOnly LaunchDarkly API access tokens (personal or service tokens) are valid for authentication with this client. Using SDK keys, mobile keys, or client-side IDs (which are designed for SDKs) will result in authentication failures when using the `launchdarkly-api` client.fixGenerate an API access token from your LaunchDarkly account's 'Authorization' settings and ensure it has the necessary permissions for the API calls you intend to make.
affects: All versions
breakingFrequent API updates lead to changes in data models and endpoint behaviors. For example, in v19.0.0, the `status` field in `IterationRep` objects changed from a string to an enum, and in v22.0.0, the `guardrail` type was removed for `POST /api/v2/projects/{projectKey}/metric-groups`. Code relying on specific string values or previously available fields/types may break.fixConsult the release notes and API documentation for each major version upgrade to adapt your code to changes in data models, request/response structures, and available parameters.
affects: v19.0.0+, v22.0.0+ (and likely other versions due to frequent changes)
Errors
Common errors & fixes
launchdarkly_api.exceptions.ApiException: (401) Reason: Unauthorized
The API access token provided in the client configuration is either missing, incorrect, expired, or lacks the necessary permissions for the requested operation.
fixVerify that your API access token is correct, has not expired, and has the appropriate roles and permissions (e.g., 'Writer' role for modifications, or a specific API version assigned to the token) in your LaunchDarkly account. Ensure you are using an API access token, not an SDK key.
AttributeError: 'DefaultApi' object has no attribute 'get_users'
The specific API endpoint or method (e.g., related to the 'Users' API) you are trying to call has been removed or significantly changed in a newer version of the LaunchDarkly REST API, often due to breaking changes across versions (e.g., the removal of the Users, Users (beta), and User settings APIs in REST API version 20240415).
fixConsult the LaunchDarkly REST API migration guide for the specific API version you are targeting (e.g., '20240415') to identify the correct endpoint, method, or alternative approach. Update your code accordingly and ensure your API calls are compatible with the specified `LD-API-Version` header or the version associated with your access token.
launchdarkly_api.exceptions.ApiException: (400) Reason: Bad Request
The request body or parameters sent to the LaunchDarkly API are malformed, missing required fields, or contain invalid data according to the API's schema for the targeted endpoint and version.
fixReview the LaunchDarkly API documentation for the specific endpoint and API version you are using to ensure all required parameters are provided, and that data types and formats in the request body are correct. Pay close attention to changes in payload structure or required fields between API versions.
ModuleNotFoundError: No module named 'launchdarkly_api'
The `launchdarkly-api` Python package is either not installed in the current environment, or there is a typo in the import statement.
fixInstall the package using `pip install launchdarkly-api` and ensure the import statement `import launchdarkly_api` (or `from launchdarkly_api.rest import ApiException` for exceptions) is correctly spelled and refers to the installed package.
Upgrade
Version history
22.0.0latest on PyPI · released Mar 5, 2026
Audit
Dependencies
No dependency data recorded yet.