Skip to main content

bidarhq-sdk-python

A lightweight error and event reporting SDK for Python applications, with optional Django integration. Reports are submitted in the background so application request handling does not wait for the remote API.

Author: CyberHuginn
Organization: Fardad Noavar
Website: cyberhuginn.com
Organization website: fardadnoavar.ir
Contact: contact@cyberhuginn.com

Installation

pip install bidarhq

Quick start

import bidarhq

bidarhq.init(
    url="https://api.bidarhq.ir/api/v1/errors/",
    access_key="YOUR_ACCESS_KEY",
    project_name="billing-api",
    environment="Production",
    log_level="error",
    timeout=3.0,
)

try:
    run_job()
except Exception as exc:
    bidarhq.capture_exception(exc)

Reports are queued on a background worker. capture_exception, capture_message, and capture_event return immediately with a boolean indicating whether the event was accepted for processing.

Django integration

Add the middleware to settings.py:

MIDDLEWARE = [
    # ...
    "bidarhq.middleware.BidarMiddleware",
]

Configure the SDK:

bidarhq = {
    "URL": "https://api.bidarhq.ir/api/v1/errors/",
    "ACCESS_KEY": "YOUR_ACCESS_KEY",
    "PROJECT_NAME": "my-django-app",
    "ENVIRONMENT": "Production",
    "LOG_LEVEL": "error",
    "TIMEOUT": 3.0,
    "ENABLED": True,
    "MIDDLEWARE_ENABLED": True,
    "CAPTURE_REQUEST_BODY": False,
    "DEDUPLICATION_WINDOW": 30,
    "MAX_WORKERS": 2,
}

The middleware reports unhandled exceptions and re-raises the original exception. Set MIDDLEWARE_ENABLED to False to disable automatic middleware reporting without removing the middleware from MIDDLEWARE.

The SDK is initialized lazily from BIDAR when the middleware first runs. You can also call bidarhq.init(...) explicitly during application startup.

Manual reporting

import bidarhq

bidarhq.capture_exception(error)

bidarhq.capture_message(
    "Payment provider is unavailable",
    level="warning",
)

bidarhq.capture_event(
    {"event": "subscription.renewal_failed", "customer_id": 42},
    level="error",
)

Configuration

Option Default Description
url Required HTTP endpoint that receives JSON POST reports
access_key Required API key sent in X-Bidar-Access-Key
log_level error One of info, warning, or error
project_name None Project identifier attached to every event
environment Production Deployment environment
timeout 3.0 Outbound HTTP timeout in seconds
enabled True Enables or disables all reporting
middleware_enabled True Enables or disables Django middleware reporting
capture_request_body False Opt-in request body capture
deduplication_window 30 Suppresses identical events within this many seconds; set to 0 to disable
max_workers 2 Number of background HTTP workers

Log levels are threshold-based: info accepts all levels, warning accepts warnings and errors, and error accepts errors only.

Reliability and privacy

  • Network requests run in a background thread pool.
  • HTTP failures, serialization errors, and worker failures are contained and do not propagate into application code.
  • flush() waits for submitted reports; shutdown() flushes and closes the client.
  • Duplicate reports with the same event fingerprint are suppressed during the configured deduplication window.
  • Authorization, cookies, passwords, tokens, secrets, and API-key-like fields are redacted.
  • Request bodies are not captured by default. Enable CAPTURE_REQUEST_BODY only after reviewing the data your application sends.
  • The SDK does not intentionally collect local variables or environment variables.

Lifecycle

bidarhq.flush()
bidarhq.shutdown()

Call flush() during controlled shutdown if pending reports should be given a chance to finish. shutdown() prevents further submissions until the SDK is initialized again.

License

MIT

Metadata

Release files for bidarhq 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bidarhq 0.0.1
File Size Uploaded Provenance Actions
bidarhq-0.0.1.tar.gz 4.8 kB Without provenance Details for bidarhq-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bidarhq 0.0.1
File Interpreter ABI Platform Actions
bidarhq-0.0.1-py3-none-any.whl Python 3 none any Details for bidarhq-0.0.1-py3-none-any.whl

Total release size: 8.5 kB

Release files / bidarhq-0.0.1.tar.gz

Download URL bidarhq-0.0.1.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
800de8f1f2bba2d5f23dfc2e9d113e7a9dbb48f3771e4dfe062042900aeb6e54
BLAKE2b-256 checksum
How to use checksums
a7d754c2a12f387940a734e8873e3c0d6aa8c6b63663ebc2af9fb5884a3a48c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / bidarhq-0.0.1-py3-none-any.whl

Download URL bidarhq-0.0.1-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
09385cf1bad6799980e0450400ac3863054d2e80a79929135ff47e694e996189
BLAKE2b-256 checksum
How to use checksums
c566c3ffc924d7c9f35378c8cf0705eaa5f8a4fc9dc09fa5f55c84ce68954098
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for bidarhq 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page