pgw-api
Python API client for Philadelphia Gas Works (PGW). Fetches natural gas usage data (monthly, daily, and hourly) from the PGW customer portal.
Installation
pip install pgw-api
Usage
import asyncio
import aiohttp
from pgw_api import PGWApiClient
async def main():
client = PGWApiClient("your-email@example.com", "your-password")
async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar()) as session:
usage = await client.async_get_usage(session)
for entry in usage:
print(f"{entry.month:%B %Y}: {entry.ccf} CCF ({entry.cf} ft³)")
if entry.period_start and entry.period_end:
print(f" Period: {entry.period_start} to {entry.period_end}")
asyncio.run(main())
API
PGWApiClient(username, password)
Creates a client instance with PGW portal credentials.
await client.async_get_usage(session)
Authenticates and returns a list of GasUsage objects sorted by month (newest first).
await client.async_get_daily_usage(session, start, end)
Authenticates and returns a list of DailyGasUsage objects for the given date range (newest first). Requires a smart meter — most residential accounts only have monthly data and will return an empty list.
from datetime import date
daily = await client.async_get_daily_usage(session, date(2024, 1, 1), date(2024, 1, 31))
for entry in daily:
print(f"{entry.date}: {entry.ccf} CCF")
await client.async_get_hourly_usage(session, usage_date)
Authenticates and returns a list of HourlyGasUsage objects for a single day (newest first). Requires a smart meter that reports interval data. Most residential accounts only have monthly data and will return an empty list.
from datetime import date
hourly = await client.async_get_hourly_usage(session, date(2024, 1, 15))
for entry in hourly:
print(f"{entry.timestamp}: {entry.ccf} CCF")
await client.async_validate_credentials(session)
Validates credentials without fetching usage data. Returns True or raises PGWAuthError.
GasUsage
| Property | Type | Description |
|---|---|---|
month |
date |
First of the billing month |
ccf |
float |
Usage in hundreds of cubic feet |
cf |
float |
Usage in cubic feet (CCF × 100) |
period_start |
date | None |
Meter read start date |
period_end |
date | None |
Meter read end date |
DailyGasUsage
| Property | Type | Description |
|---|---|---|
date |
date |
Usage date |
ccf |
float |
Usage in hundreds of cubic feet |
cf |
float |
Usage in cubic feet (CCF × 100) |
HourlyGasUsage
| Property | Type | Description |
|---|---|---|
timestamp |
datetime |
Usage timestamp |
ccf |
float |
Usage in hundreds of cubic feet |
cf |
float |
Usage in cubic feet (CCF × 100) |
Exceptions
PGWAuthError— invalid credentials or expired sessionPGWConnectionError— network or portal issuesPGWError— base exception class
Release files for pgw-api 1.3.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 | |
|---|---|---|---|
| pgw_api-1.3.1.tar.gz | 10.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pgw_api-1.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.9 kB
Release files / pgw_api-1.3.1.tar.gz
| Download URL | pgw_api-1.3.1.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a627652b2117b890259c7b908a1a3c50a291d1aed6e5518a59b6d82500b453fd
|
|
BLAKE2b-256 checksum How to use checksums |
78f69ed7fc92945f9cf507c41483ceaa6bfe3d16337e5dee289d838978756263
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / pgw_api-1.3.1-py3-none-any.whl
| Download URL | pgw_api-1.3.1-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a05fd4a69b97b33737c9ffe0aff64a10b4ebb0946b4172f36e0b355e05b37278
|
|
BLAKE2b-256 checksum How to use checksums |
9f7a42da06fd4a4b6cbf1894fcf0e260c37e856fbc45c26e6eba59f2d69be37c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency log