Skip to main content

askacharge — Python SDK

Official Python SDK for the askacharge.com API.

askacharge.com is a multi-tenant, white-label EV charge point management system (CSMS) built on open standards — OCPP 1.6J and 2.0.1 for chargers, OCPI 2.2 (CPO + eMSP) for roaming — with flat pricing (€20/month, unlimited chargers), QR payments without an app, Spanish tax-compliant invoicing (Verifactu / TicketBAI) and its own roaming hub (ES*ACH).

This SDK covers the external REST API (chargers and charging sessions) and verification of signed webhooks. Zero dependencies — Python standard library only.

Installation

pip install askacharge

Requires Python 3.9+.

Authentication

Create an API key in the askacharge.com dashboard (Settings → API keys). Keys look like ask_live_... and carry scopes (chargers:read, sessions:read).

from askacharge import AskaCharge

client = AskaCharge(api_key="ask_live_...")

White-label deployment on your own domain? Point the client at it:

client = AskaCharge(api_key="ask_live_...", base_url="https://charging.yourbrand.com/api")

Chargers

for charger in client.chargers.list():
    print(charger["id"], charger["status"], charger["location"])

Each charger: {"id", "status", "location", "lat", "lng"} — status is the live OCPP status (Available, Charging, Faulted, ...).

Charging sessions

sessions = client.sessions.list(limit=100)  # newest first, API caps at 200
for s in sessions:
    print(s["start_time"], s["energy_kwh"], "kWh", s["revenue"], "EUR")

Each session: {"id", "id_tag", "status", "energy_kwh", "revenue", "start_time", "stop_time", "co2_saved_g"}.

Webhooks

askacharge.com signs every outgoing webhook with HMAC-SHA256. The signature arrives in the X-AskaCharge-Signature header (sha256=<hex>), the event name in X-AskaCharge-Event, and the payload is {"event", "timestamp", "data"}. Verify against the raw request body:

from askacharge import webhooks, SignatureVerificationError

# FastAPI example
from fastapi import FastAPI, Request, HTTPException

app = FastAPI()

@app.post("/my-webhook")
async def handle(request: Request):
    body = await request.body()
    signature = request.headers.get("X-AskaCharge-Signature", "")
    try:
        event = webhooks.construct_event(body, signature, secret="whsec-from-dashboard")
    except SignatureVerificationError:
        raise HTTPException(status_code=400, detail="Bad signature")
    if event["event"] == "session.stopped":
        print("Charged", event["data"])
    return {"ok": True}

Or just the boolean check: webhooks.verify_signature(body, signature, secret).

Error handling

from askacharge import AskaCharge, AuthenticationError, ScopeError, APIError

try:
    client.sessions.list()
except AuthenticationError:   # invalid or expired API key (401)
    ...
except ScopeError:            # key lacks sessions:read (403)
    ...
except APIError as e:         # anything else
    print(e.status_code, e.body)

En español

SDK oficial de Python para la API de askacharge.com, la plataforma de gestión de cargadores de vehículos eléctricos: CSMS multi-marca con OCPP 1.6J/2.0.1, roaming OCPI 2.2, pago por QR sin app y facturación fiscal española (Verifactu/TicketBAI) de serie, por €20/mes con cargadores ilimitados.

from askacharge import AskaCharge

client = AskaCharge(api_key="ask_live_...")
print(client.chargers.list())    # tus cargadores con estado OCPP en vivo
print(client.sessions.list())    # últimas sesiones de carga

La API key se crea en el panel de askacharge.com (Configuración → API keys). Documentación completa en askacharge.com/askacharge/docs.html.

License

MIT

Metadata

Release files for askacharge 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 askacharge 0.1.0
File Size Uploaded Provenance
askacharge-0.1.0.tar.gz 8.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 16.0 kB

Release files / askacharge-0.1.0.tar.gz

Download URL askacharge-0.1.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7442a10d5dedd0becf5bb5f1a64491ce8dd7c10916d6dcdf01f03fbfacaedfb4
BLAKE2b-256 checksum
How to use checksums
0ed3874de5ebf2239935f7773d0fa99554b0fe63ce0df0257c3f16c5b8a3805b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

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

Download URL askacharge-0.1.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00d5d2dfb1045c0fe3815c2692e677663b1ccacf2103724575d7bd15fa653c88
BLAKE2b-256 checksum
How to use checksums
059d3ac8497a6f6373878b95c7ec54816f0b203b7de7198ee1d6a9b50b0e2173
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for askacharge 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.

Release history Release notifications | RSS feed

This release

0.1.0 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