A small Python script that pulls historical inverter/battery data from the FoxESS Open API and saves it as CSV, ready for analysis (e.g. self-consumption, self-sufficiency, battery cycling, export/import timing).
- Authenticates against the FoxESS Open API using MD5-signed request headers
- Pulls 5-minute interval data for a full calendar month, looping day-by-day (the API only accepts a 1-day range per call)
- Handles the current month gracefully — stops at yesterday instead of requesting future dates that don't exist yet
- Writes output to
foxess_history_YYYY-MM.csv
-
Clone this repo and install dependencies:
pip install -r requirements.txt
-
Get your API key from the FoxESS Cloud portal:
foxesscloud.com→ User Profile → API Management → generate a key. -
Get your inverter's serial number (SN) from the same portal, or by calling the
/op/v0/device/listendpoint (seeget_device_list()in the script). -
Copy
.env.exampleto.envand fill in your real values:cp .env.example .env
FOXESS_API_KEY=your_actual_api_key FOXESS_DEVICE_SN=your_actual_device_sn.envis already covered by.gitignore— it will never be committed.
python foxess_export.py MM-YYYYExample — pull all of August 2026:
python foxess_export.py 08-2026This produces foxess_history_2026-08.csv with columns:
time, pvPower, loadsPower, feedinPower, gridConsumptionPower, batChargePower, batDischargePower, SoC
The variables pulled from the API can be changed by editing the VARIABLES list near the top of foxess_export.py. Defaults:
VARIABLES = ["pvPower", "loadsPower", "feedinPower", "gridConsumptionPower",
"batChargePower", "batDischargePower", "SoC"]- The FoxESS history endpoint only accepts single-day ranges — multi-day requests return
errno 40257. This script already loops day-by-day to work around that. - Timestamps in the CSV include a timezone suffix (e.g.
BST+0100). Strip or convert this before parsing withpandas.to_datetime. - The API's "yield"/generation figures can differ slightly from what the FoxESS app shows, since yield includes all inverter output (including battery-sourced), not just solar production.
- API calls are rate-limited to roughly 1 request/second; the script already sleeps between calls to stay under this.
MIT — do whatever you like with it.