Python SDK for the Corsa compliance and risk API
Project description
Corsa Python SDK
Python client for the Corsa compliance and risk API.
Auto-generated from the Corsa OpenAPI specification using openapi-python-client, with typed Pydantic v2 models and both sync/async httpx clients.
Installation
pip install corsa-sdk
Quick Start
Sync
from corsa_sdk import CorsaClient
from corsa_sdk.models.create_alert_dto import CreateAlertDto
client = CorsaClient(
base_url="https://api.corsa.finance",
token="your-api-token",
)
alert = client.alerts.create_alert(body=CreateAlertDto(
name="Suspicious activity",
description="Large transfer flagged",
))
client.close()
Async
from corsa_sdk import AsyncCorsaClient
from corsa_sdk.models.create_alert_dto import CreateAlertDto
async with AsyncCorsaClient(
base_url="https://api.corsa.finance",
token="your-api-token",
) as client:
alert = await client.alerts.create_alert(body=CreateAlertDto(
name="Suspicious activity",
description="Large transfer flagged",
))
Context Manager (sync)
with CorsaClient(base_url="https://api.corsa.finance", token="your-api-token") as client:
case = client.cases.get_case(case_id="abc-123")
API Namespaces
The client exposes each API tag as an attribute. Endpoint names match the generated module names.
| Namespace | Examples |
|---|---|
client.alerts |
create_alert, get_alert, update_alert, bulk_assign_alert |
client.cases |
create_case, get_case, update_case, bulk_update_case_status |
client.clients |
create_individual_client, create_corporate_client, get_individual_client |
client.transactions |
get_transaction_by_id, update_transaction, update_transaction_status |
client.blockchain_wallets |
create_blockchain_wallet, get_blockchain_wallet |
client.bank_accounts |
create_bank_account, get_bank_account |
client.rules |
create_rule, list_rules, activate_rule, disable_rule |
client.rule_templates |
list_rule_templates, get_rule_template, copy_rule_template |
client.deposits |
create_deposit, get_deposit |
client.withdrawals |
create_withdrawal, get_withdrawal |
client.trades |
create_trade, get_trade, add_transaction |
client.sessions |
create_session, get_session, get_client_sessions |
client.members |
create_individual_member, create_corporate_member |
client.attachments |
upload_attachments, get_attachments_by_entity |
client.checklists |
create_checklist_template, update_checklist_item |
client.evaluation |
evaluate, get_rule_evaluations |
client.platform |
get_encryption_configuration |
Advanced Usage
Direct module access
For full control over the response (status code, headers), use the generated modules directly:
from corsa_sdk import AuthenticatedClient
from corsa_sdk.api.alerts import create_alert
from corsa_sdk.models.create_alert_dto import CreateAlertDto
client = AuthenticatedClient(base_url="https://api.corsa.finance", token="your-api-token")
# Returns a Response object with status_code, headers, and parsed body
response = create_alert.sync_detailed(client=client, body=CreateAlertDto(...))
print(response.status_code, response.headers)
alert = response.parsed
Custom headers and timeout
client = CorsaClient(
base_url="https://api.corsa.finance",
token="your-api-token",
timeout=60.0,
headers={"X-Custom-Header": "value"},
)
Access the underlying httpx client
raw = client.raw_client.get_httpx_client()
Webhook Verification
Verify incoming webhook signatures using HMAC-SHA256:
from corsa_sdk import verify_webhook_signature, sign_webhook_payload
# Verify a webhook from Corsa
is_valid = verify_webhook_signature(
secret="your-webhook-secret",
event_payload=request.body,
signature=request.headers["X-Signature"],
)
# Sign a payload (for testing)
sig = sign_webhook_payload("your-webhook-secret", '{"event":"alert.created"}')
Error Handling
from corsa_sdk.errors import UnexpectedStatus
try:
alert = client.alerts.get_alert(alert_id="nonexistent")
except UnexpectedStatus as e:
print(f"HTTP {e.status_code}: {e.content}")
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Lint
ruff check .
# Type check
mypy corsa_sdk/
How the SDK is Generated
This SDK is auto-generated from the Corsa API Gateway OpenAPI specification:
- A GitHub Actions workflow runs hourly and fetches the latest
api-spec.jsonfrom staging openapi-python-clientgenerates typed Python models and API modules- Generated code is merged into the repo (preserving manual modules like
webhooks/andcorsa_client.py) - A PR is opened for review; on merge,
python-semantic-releasepublishes to PyPI
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file corsa_sdk-1.9.0.tar.gz.
File metadata
- Download URL: corsa_sdk-1.9.0.tar.gz
- Upload date:
- Size: 232.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b78b992d367bb5ad3814c38529df2ae252e9871c7f6f24ec3b7a811e50d57bff
|
|
| MD5 |
5c3e5b60eb505e67eeec02d8b99e6ba8
|
|
| BLAKE2b-256 |
3ca3620ac15d1c6a719f9a035fbf28ed9f42ae90d0f326e96ef8e3674af9f052
|
Provenance
The following attestation bundles were made for corsa_sdk-1.9.0.tar.gz:
Publisher:
release.yaml on corsa-labs/corsa-sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
corsa_sdk-1.9.0.tar.gz -
Subject digest:
b78b992d367bb5ad3814c38529df2ae252e9871c7f6f24ec3b7a811e50d57bff - Sigstore transparency entry: 1393471484
- Sigstore integration time:
-
Permalink:
corsa-labs/corsa-sdk-py@ea37d2537603053bf9600f54cda6d618c0b723ba -
Branch / Tag:
refs/heads/main - Owner: https://github.com/corsa-labs
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@ea37d2537603053bf9600f54cda6d618c0b723ba -
Trigger Event:
push
-
Statement type:
File details
Details for the file corsa_sdk-1.9.0-py3-none-any.whl.
File metadata
- Download URL: corsa_sdk-1.9.0-py3-none-any.whl
- Upload date:
- Size: 658.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c53411ea959d3fc9617e61e3539973acc9b8a02ff578f0cb299e8fc920cfb52d
|
|
| MD5 |
ea991eac7a5cc1fbd0d822374274a158
|
|
| BLAKE2b-256 |
aa40529cf0440e621e582c39359ef5477a3f1039f696f7c147ba35e159f16a1d
|
Provenance
The following attestation bundles were made for corsa_sdk-1.9.0-py3-none-any.whl:
Publisher:
release.yaml on corsa-labs/corsa-sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
corsa_sdk-1.9.0-py3-none-any.whl -
Subject digest:
c53411ea959d3fc9617e61e3539973acc9b8a02ff578f0cb299e8fc920cfb52d - Sigstore transparency entry: 1393471507
- Sigstore integration time:
-
Permalink:
corsa-labs/corsa-sdk-py@ea37d2537603053bf9600f54cda6d618c0b723ba -
Branch / Tag:
refs/heads/main - Owner: https://github.com/corsa-labs
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@ea37d2537603053bf9600f54cda6d618c0b723ba -
Trigger Event:
push
-
Statement type: