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

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 = {
    "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 bidar.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.flush()
bidar.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.2.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 bidar 0.2.1
File Size Uploaded Provenance Actions
bidar-0.2.1.tar.gz 10.3 kB Without provenance Details for bidar-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 19.5 kB

Release files / bidar-0.2.1.tar.gz

Download URL bidar-0.2.1.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3ded9e5f533daa974eb9310891e25b75eac0ceb0bbc982302727f2518e35fdf2
BLAKE2b-256 checksum
How to use checksums
ece459b48bc8a50da66c83ce200873af57a3faca52c0fd5073a7ea54c2119abd
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.2.1-py3-none-any.whl

Download URL bidar-0.2.1-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63fce31c046f12b168d7d7eca4d8bed7a0922b2840359b1aaee9667bd0573131
BLAKE2b-256 checksum
How to use checksums
f0e8c4c3a43ad1160dd113a2ddce341f2400e20876e63799dda85d6521eaffbd
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.2.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.

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