Skip to main content

pychargefox

Async Python client for the Chargefox GraphQL API.

[!WARNING] This is an unofficial project and is not affiliated with, endorsed by, or connected to Chargefox. It uses an undocumented GraphQL API that may change or stop working without notice.

[!NOTE] This project was developed with AI-assisted coding. Its behavior has been reviewed and tested, but users should independently evaluate it before relying on it.

Install

pip install pychargefox

For local development, install the project into its virtual environment in editable mode:

python -m pip install --editable ".[dev]"

Example

import asyncio

from chargefox import Bounds, ChargefoxClient


async def main() -> None:
    async with ChargefoxClient() as client:
        stations = await client.get_charge_stations_by_bounds(
            Bounds(south=-32.5, west=115.0, north=-31.0, east=116.5)
        )

        for station in stations:
            print(station.name, station.status, station.online)
            for connector in station.connectors:
                plug_name = connector.plug.short_name if connector.plug else "Unknown"
                print(plug_name, connector.status)

                if connector.active_charge_session:
                    session = connector.active_charge_session
                    charge_rate_kw = (
                        session.charge_rate.value_kw if session.charge_rate else None
                    )
                    consumption_kwh = (
                        session.total_consumption / 1000
                        if session.total_consumption is not None
                        else None
                    )
                    print(session.current_state, charge_rate_kw, consumption_kwh)


asyncio.run(main())

The current public queries do not require authentication. A bearer token can still be supplied for endpoints that require one:

client = ChargefoxClient(bearer_token="YOUR_TOKEN")

Behaviour

  • get_locations_by_bounds() returns lightweight map summaries.
  • get_charge_stations_by_bounds() hydrates those summaries through location(id) and returns fully modelled stations, connectors, plugs, and active sessions.
  • Bounds hydration uses at most 10 concurrent requests by default. Successful locations are returned when isolated locations fail; if every location fails, the first error is raised.
  • get_location(), get_charge_station(), and get_connector() support targeted polling.
  • Active-session consumption is returned by the API in Wh; divide it by 1000 for kWh.

The concurrency limit can be configured with ChargefoxClient(max_concurrent_requests=5).

Development checks

python -m ruff format --check .
python -m ruff check .
python -m unittest discover -s tests -v
python -m coverage run -m unittest discover -s tests
python -m coverage report

Build a wheel into dist/ with:

python -m pip wheel . --no-deps --wheel-dir dist

Live integration test

Set CHARGEFOX_RUN_LIVE_TESTS=1, then run the normal test suite. The live tests use the public API without authentication and are skipped unless explicitly enabled.

py -m unittest discover -s tests

If you need to override the endpoint, set CHARGEFOX_GRAPHQL_URL as well.

The live tests cover lookup collections, lightweight map discovery, and resolving a full location and its stations from a map result. Connector status and active-session data are included with each full station and can be refreshed by polling the location, station, or connector methods.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pychargefox-0.1.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pychargefox-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file pychargefox-0.1.0.tar.gz.

File metadata

  • Download URL: pychargefox-0.1.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for pychargefox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4aa17d5ffaf90d42b385ecf3d526bc9613c5b5879c9a9b505997bc8723ce4efe
MD5 46e33562b1c11ea558b8aedc072be2d3
BLAKE2b-256 62d1fb09d4e5bb16607fbf4e32a7a70f3d34aaf4e15b96dd484a8d099a860ab5

See more details on using hashes here.

File details

Details for the file pychargefox-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pychargefox-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for pychargefox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 154cc1fe03771a866cf821ba3b27b9bbc043a5a9911a0ada44b6b736443bf2b4
MD5 acb1cccae9440ed0ecc398835f2b41ec
BLAKE2b-256 b15b6c5fdbe331090ef7eff8f219e39b76d8607e2a1343af0ed91abbc5e1f304

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page