Registry / http-networking / crowdstrike-falconpy

crowdstrike-falconpy

JSON →
library1.6.5pypypi✓ verified 25d ago

CrowdStrike FalconPy is the official Python SDK for interacting with CrowdStrike Falcon APIs. It provides a standardized way to access various CrowdStrike services, enabling automation and integration. The library is currently at version 1.6.1 and receives frequent updates, typically focusing on new API operations, bug fixes, and minor enhancements.

pip install crowdstrike-falconpy
INSTALL
IMPORT
SIG · CROWDSTRIKE-FALCON
C
crowdstrike-falconpy
http-networkingpythonv1.6.5
Install
2.7s avg
Import
764ms
Disk
33MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.6.5 · 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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.834s · 34.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.7s · import 0.694s · 35MB
33MB installed
● package 33MB
Code
Verified usage

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

APIHarness
from falconpy import APIHarness
from falconpy.api_harness import APIHarness
The primary API client is directly exposed under the top-level 'falconpy' package, not within submodules like 'api_harness'.
HostGroup
from falconpy import HostGroup
Service classes like 'HostGroup' are also directly exposed at the top-level package.

This quickstart demonstrates how to initialize the FalconPy APIHarness client using environment variables for authentication and retrieve the CrowdStrike Customer ID (CID). It highlights the recommended practice of externalizing credentials and includes basic error handling for API responses.

import os from falconpy import APIHarness # Retrieve credentials from environment variables client_id = os.environ.get('FALCON_CLIENT_ID', '') client_secret = os.environ.get('FALCON_CLIENT_SECRET', '') base_url = os.environ.get('FALCON_BASE_URL', 'https://api.crowdstrike.com') if not client_id or not client_secret: print("Please set FALCON_CLIENT_ID and FALCON_CLIENT_SECRET environment variables.") else: try: # Initialize the APIHarness client falcon = APIHarness(client_id=client_id, client_secret=client_secret, base_url=base_url) # Example: Get the Customer ID (CID) response = falcon.get_cid() if response['status_code'] == 200: print(f"Successfully connected. Customer ID: {response['body']['cid']}") else: print(f"Error getting CID: {response['status_code']} - {response.get('body', {}).get('errors', 'Unknown error')}") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingPython 3.7 support was dropped in FalconPy v1.6.0. Projects using Python 3.7 or older will fail to install or run this version.
fix
Upgrade your Python environment to version 3.8 or newer before upgrading to FalconPy v1.6.0+.
affects: >=1.6.0
deprecatedSpecific API operations are periodically deprecated or replaced. For example, `combinedUserRolesV1` was deprecated in v1.5.1 in favor of `CombinedUserRolesV2`.
fix
Always refer to the official CrowdStrike API documentation for the latest operation names and best practices. Monitor release notes for deprecated operations and update your code accordingly.
affects: >=1.5.1
gotchaThe `base_url` parameter must be set correctly for your CrowdStrike cloud region (e.g., api.us-1.crowdstrike.com, api.eu-1.crowdstrike.com). The default is `https://api.crowdstrike.com` (US-1).
fix
Explicitly pass the `base_url` argument to your `APIHarness` or service class initializer, e.g., `APIHarness(..., base_url='https://api.eu-1.crowdstrike.com')`.
affects: All versions
gotchaAPI responses should always be checked for `status_code` and the presence of an `errors` key in the response body. A successful HTTP status code (e.g., 200) does not always guarantee the absence of application-level errors.
fix
After any API call, inspect `response['status_code']` and `response.get('body', {}).get('errors')` to ensure both HTTP and application-level success.
affects: All versions
gotchaService collection names and their associated operations can change over time. For example, 'Compliance Assessments' was renamed to 'Container Image Compliance' in v1.4.9.
fix
Consult the `falconpy` release notes and the CrowdStrike API documentation when upgrading to ensure you are using the correct service class and operation names for your version.
affects: All versions, especially major/minor updates
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'falconpy'
This error occurs when the `crowdstrike-falconpy` library has not been installed correctly, or the Python environment running the script does not have access to the installed package. This often happens if the installation command `pip install crowdstrike-falconpy` was not run, or the script is being executed outside of the virtual environment where it was installed.
fix
Ensure the library is installed in the active Python environment using pip: `python3 -m pip install crowdstrike-falconpy` or `pip install crowdstrike-falconpy`. If using a virtual environment (e.g., venv, pipenv, poetry), activate it before installing and running the script.
ImportError: cannot import name 'SensorUpdatePolicies' from 'falconpy'
This error typically arises when attempting to import a service class using an incorrect name, such as a pluralized version when the singular is required, or vice-versa, or if the class name itself is misspelled. FalconPy has evolved its naming conventions (e.g., singular vs. plural aliases) over versions.
fix
Verify the exact class name and its casing in the `falconpy` documentation for the specific API service you are trying to access. For example, `SensorUpdatePolicies` might need to be `SensorUpdatePolicy` or imported from `from falconpy import SensorUpdatePolicy`. For versions v0.7.1 and later, both singular and plural aliases might be supported, but checking the documentation for the specific version is best.
{'status_code': 403, 'message': 'access denied, authorization failed'}
A 403 Forbidden status code with an 'access denied, authorization failed' message indicates that the API credentials (client ID and client secret) used to make the request do not have the necessary permissions (scopes) assigned in the CrowdStrike Falcon API console for the specific operation being attempted.
fix
Review the required API scopes for the specific CrowdStrike API endpoint you are calling within the CrowdStrike API documentation. Then, update your API client in the CrowdStrike Falcon console to include all necessary read/write/admin permissions. Ensure the correct `client_id` and `client_secret` are being passed to your FalconPy class instance.
'invalid bearer token' error
This error indicates that the authentication token used for the API request is either expired, incorrectly formed, or the provided `client_id` and `client_secret` are invalid or lack the permissions to generate a valid token.
fix
Double-check your `client_id` and `client_secret` for typos. Ensure the API keys are active in your CrowdStrike Falcon console. FalconPy handles token renewal automatically, so if this error occurs, it's usually an initial credential issue or a fundamental misconfiguration rather than an expired token during a long-running session.
Upgrade
Version history
1.6.5latest on PyPI · released Aug 20, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
1
Resources
crowdstrike-falconpy — pip install crowdstrike-falconpy · libregistry