Filigran SSEClient provides a Python API client specifically designed for consuming Server-Sent Events (SSE) from OpenCTI platforms. It simplifies connection management, event parsing, and authentication for real-time data streaming from OpenCTI. The current version is 1.0.2, and releases are typically made to address bug fixes or minor enhancements.
pip install filigran-sseclientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to connect to an OpenCTI Server-Sent Events stream using `filigran-sseclient`. It initializes an `SSEClient` with a base URL and API key (retrieved from environment variables for security) and then iterates through incoming events. Remember to replace placeholder values with your actual OpenCTI instance details and ensure `OPENCTI_API_KEY` is securely configured.
After receiving an event, use `import json` and then `data_payload = json.loads(event.data)` to access the structured data. Implement conditional logic based on `event.event` for proper handling.
Implement custom retry logic around the `client.events()` loop using libraries like `tenacity` or a `while True` loop with backoff and error logging to ensure continuous operation.
Double-check `OPENCTI_BASE_URL` and `OPENCTI_API_KEY` values. Ensure the API key has the necessary permissions. Add explicit `try...except requests.exceptions.HTTPError as e:` blocks to catch authentication-related status codes (e.g., 401, 403).
Run `pip install filigran-sseclient` in your active Python environment.
Change `token=your_token` to `api_key=your_api_key` when initializing `SSEClient`.
Verify that `OPENCTI_BASE_URL` is correct and accessible. Check network connectivity to the OpenCTI instance. If using proxies, ensure they are configured correctly for the `requests` library (e.g., via `http_proxy`/`https_proxy` environment variables).