BCHydro API
BCHydro Python API for extracting electricity usage statistics from your personal account.
Installation
Via PyPi:
pip install bchydro
Via Github:
# Fetch the code
git clone https://github.com/emcniece/bchydro.git
cd bchydro
# Set up environment
pip install -r requirements.txt
Usage
Running the example script:
pip install bchydro
export BCH_USER=your.email@domain.com
export BCH_PASS=your-bch-password
python test.py
Using in a project:
import asyncio
from bchydro import BCHydroApi
async def main():
bch = BCHydroApi("username", "password")
# Asynchronous usage:
print(await bch.get_usage())
print(await bch.get_latest_point())
print(await bch.get_latest_usage())
print(await bch.get_latest_interval())
print(await bch.get_latest_cost())
# Mostly synchronous usage:
await bch.refresh()
print(bch.usage)
print(bch.latest_point)
print(bch.latest_usage)
print(bch.latest_interval)
print(bch.latest_cost)
asyncio.run(main())
⚠ Read-Only Account Sharing
This project accesses your BCHydro account as would a human in a browser. It is recommended that a read-only account is set up for use with this project for more secure operation. Using this secondary account also enables backup access in the event of account lockout.
- Instructions for adding read-only accounts can be found here.
- Read-only accounts can be configured here after logging in.
Version Publishing
This repo is automatically published to PyPi by means of a Github Workflow when a new release is created on Github.
Maintenance
Dependencies can be updated with pip-tools:
# Install pip-compile and pip-sync
pip install pip-tools
# Upgrade requirements
pip-compile --upgrade
Todo
- Publish on release, not tag
- Handle account locking (looks for HTML alert dialogs)
- Unit tests
- Automatic initial and re-authentication
- Rate limiting, auth retries
- Exception documentation
Disclaimer
This package has been developed without the express permission of BC Hydro. It accesses data by submitting forms that end-users would typically use in a browser. I'd love to work with BC Hydro to find a better way to access this data, perhaps through an official API... if you know anyone that works there, pass this along!
Metadata
Release files for bchydro 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| bchydro-0.8.1.tar.gz | 8.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bchydro-0.8.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.0 kB
Release files / bchydro-0.8.1.tar.gz
| Download URL | bchydro-0.8.1.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
563ccd109941d232552ea182bec9331ba0d7e76ef040b6c3fe74fedcc7e7689f
|
|
BLAKE2b-256 checksum How to use checksums |
eaef77090a8a3190b4477e03b0c12ef1cc76fa3d944d9d2216d613b4f7aa06a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.7
|
Release files / bchydro-0.8.1-py3-none-any.whl
| Download URL | bchydro-0.8.1-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a96dce778c0a1eabb4a3c7f89cb43d59b080138474c1e0b5f9caaf6ec25bdc01
|
|
BLAKE2b-256 checksum How to use checksums |
d8030eedabe285469585f7e069027f510ae0ac4ede4989576087fce2980f34cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.7
|
Security for bchydro 0.8.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.