Skip to main content

bidar-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 bidar-sdk-python

For Django projects:

pip install "bidar-sdk-python[django]"

Quick start

import bidar

bidar.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:
    bidar.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 = [
    # ...
    "bidar.middleware.BidarMiddleware",
]

Configure the SDK:

BIDAR_SDK = {
    "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_SDK when the middleware first runs. You can also call bidar_sdk.init(...) explicitly during application startup.

Manual reporting

import bidar

bidar.capture_exception(error)

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

bidar.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

bidar_sdk.flush()
bidar_sdk.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 bidar 0.1.0

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

Source distribution (sdist)

Source distribution for bidar 0.1.0
File Size Uploaded Provenance Actions
bidar-0.1.0.tar.gz 10.3 kB Without provenance Details for bidar-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 19.6 kB

Release files / bidar-0.1.0.tar.gz

Download URL bidar-0.1.0.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
da1caa767e3f6a6683f26109cce58d6079b63e1b0d6d8281342d3f61692b64b7
BLAKE2b-256 checksum
How to use checksums
35c0fae31d6072f3d502b24d08e921ce853e1b296a7224b13bcf27774fe7c1cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / bidar-0.1.0-py3-none-any.whl

Download URL bidar-0.1.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b61a6229685406cd9f475ac980ac45e946bce1abf9e62e9a34e6f6c617ecee07
BLAKE2b-256 checksum
How to use checksums
a2afbdda0e8ace13628e98b06eb6dca6ae35c9609de18145474955f25e1f5dca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for bidar 0.1.0

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.

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