Skip to main content

Exnodes Report Service SDK

Version: 0.1.0

Khởi tạo client - install SDK

from exn_salon_report_sdk import ReportClient, ReportSDKException

api_key = "your_api_key"
secret_key = "your_secret_key"
client = ReportClient(api_key, secret_key)

# Gọi API để lấy báo cáo
try:
    report_id = "12345"
    report = client.get_report(report_id)
    print("Report:", report)

    # Tạo mới một báo cáo
    new_report_data = {
        "name": "Sales Report",
        "filters": {"date_range": "2025-01-01 to 2025-01-20"},
    }
    new_report = client.create_report(new_report_data)
    print("New Report Created:", new_report)
    
except ReportSDKException as e:
    print("SDK Error:", str(e))

Xử lý phía Service Report

1. Lấy API key từ header.

api_key = request.headers.get("API-Key")
if not api_key:
    return {"error": "API key is required"}, 401

secret_key = get_secret_key_from_db(api_key)
if not secret_key:
    return {"error": "Invalid API key"}, 401

2. Xác minh chữ ký

import hmac
import hashlib
import base64

def verify_signature(secret_key, signature_payload, signature):
    expected_signature = hmac.new(
        secret_key.encode(), 
        signature_payload.encode(), 
        hashlib.sha256
    ).digest()
    expected_signature = base64.b64encode(expected_signature).decode()
    return hmac.compare_digest(expected_signature, signature)

# Xử lý chữ ký
signature_payload = f"{api_key}{timestamp}{request_payload}"
if not verify_signature(secret_key, signature_payload, received_signature):
    return {"error": "Invalid signature"}, 401

3. Kiểm tra timestamp (chống replay attack):

from datetime import datetime, timedelta

def is_timestamp_valid(request_timestamp, max_skew_minutes=5):
    try:
        timestamp = datetime.fromisoformat(request_timestamp)
        now = datetime.utcnow()
        return abs((now - timestamp).total_seconds()) <= max_skew_minutes * 60
    except ValueError:
        return False

if not is_timestamp_valid(timestamp):
    return {"error": "Invalid or expired timestamp"}, 401

Metadata

Release files for exn-report-sdk 0.1.19

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

Source distribution (sdist)

Source distribution for exn-report-sdk 0.1.19
File Size Uploaded Provenance Actions
exn_report_sdk-0.1.19.tar.gz 11.4 kB Without provenance Details for exn_report_sdk-0.1.19.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for exn-report-sdk 0.1.19
File Interpreter ABI Platform Actions
exn_report_sdk-0.1.19-py3-none-any.whl Python 3 none any Details for exn_report_sdk-0.1.19-py3-none-any.whl

Total release size: 21.9 kB

Release files / exn_report_sdk-0.1.19.tar.gz

Download URL exn_report_sdk-0.1.19.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1390eef0907607b4b4c148731852ec1ae960dc3c75af0adc82e66250878c3e88
BLAKE2b-256 checksum
How to use checksums
a16f768ac7e63ce827f782d23e7ee6412dd9e59bf2997a83492bc340ab545c09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / exn_report_sdk-0.1.19-py3-none-any.whl

Download URL exn_report_sdk-0.1.19-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1b90e17d1f00b7268b4372d26e179c2a8b82de665372b920b1da7514aaf91c1
BLAKE2b-256 checksum
How to use checksums
b5223c1add240b37e2aaa78c606f60a3ab1f4f0b78d979ac98480b55c6eb6631
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for exn-report-sdk 0.1.19

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