pgw-api 1.0.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pgw_api-1.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zackwag
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
pgw_api-1.2.0/PKG-INFO ADDED
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: pgw-api
3
+ Version: 1.2.0
4
+ Summary: Python API client for Philadelphia Gas Works (PGW)
5
+ Author: zackwag
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/zackwag/pgw-api
8
+ Project-URL: Issues, https://github.com/zackwag/pgw-api/issues
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: aiohttp>=3.9.0
13
+ Dynamic: license-file
14
+
15
+ # pgw-api
16
+
17
+ Python API client for [Philadelphia Gas Works (PGW)](https://www.pgworks.com/). Fetches natural gas usage data (monthly, daily, and hourly) from the PGW customer portal.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install pgw-api
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```python
28
+ import asyncio
29
+ import aiohttp
30
+ from pgw_api import PGWApiClient
31
+
32
+ async def main():
33
+ client = PGWApiClient("your-email@example.com", "your-password")
34
+
35
+ async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar()) as session:
36
+ usage = await client.async_get_usage(session)
37
+
38
+ for entry in usage:
39
+ print(f"{entry.month:%B %Y}: {entry.ccf} CCF ({entry.cf} ft³)")
40
+ if entry.period_start and entry.period_end:
41
+ print(f" Period: {entry.period_start} to {entry.period_end}")
42
+
43
+ asyncio.run(main())
44
+ ```
45
+
46
+ ## API
47
+
48
+ ### `PGWApiClient(username, password)`
49
+
50
+ Creates a client instance with PGW portal credentials.
51
+
52
+ ### `await client.async_get_usage(session)`
53
+
54
+ Authenticates and returns a list of `GasUsage` objects sorted by month (newest first).
55
+
56
+ ### `await client.async_get_daily_usage(session, start, end)`
57
+
58
+ 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.
59
+
60
+ ```python
61
+ from datetime import date
62
+
63
+ daily = await client.async_get_daily_usage(session, date(2024, 1, 1), date(2024, 1, 31))
64
+ for entry in daily:
65
+ print(f"{entry.date}: {entry.ccf} CCF")
66
+ ```
67
+
68
+ ### `await client.async_get_hourly_usage(session, usage_date)`
69
+
70
+ 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.
71
+
72
+ ```python
73
+ from datetime import date
74
+
75
+ hourly = await client.async_get_hourly_usage(session, date(2024, 1, 15))
76
+ for entry in hourly:
77
+ print(f"{entry.timestamp}: {entry.ccf} CCF")
78
+ ```
79
+
80
+ ### `await client.async_validate_credentials(session)`
81
+
82
+ Validates credentials without fetching usage data. Returns `True` or raises `PGWAuthError`.
83
+
84
+ ### `GasUsage`
85
+
86
+ | Property | Type | Description |
87
+ |----------|------|-------------|
88
+ | `month` | `date` | First of the billing month |
89
+ | `ccf` | `float` | Usage in hundreds of cubic feet |
90
+ | `cf` | `float` | Usage in cubic feet (CCF × 100) |
91
+ | `period_start` | `date \| None` | Meter read start date |
92
+ | `period_end` | `date \| None` | Meter read end date |
93
+
94
+ ### `DailyGasUsage`
95
+
96
+ | Property | Type | Description |
97
+ |----------|------|-------------|
98
+ | `date` | `date` | Usage date |
99
+ | `ccf` | `float` | Usage in hundreds of cubic feet |
100
+ | `cf` | `float` | Usage in cubic feet (CCF × 100) |
101
+
102
+ ### `HourlyGasUsage`
103
+
104
+ | Property | Type | Description |
105
+ |----------|------|-------------|
106
+ | `timestamp` | `datetime` | Usage timestamp |
107
+ | `ccf` | `float` | Usage in hundreds of cubic feet |
108
+ | `cf` | `float` | Usage in cubic feet (CCF × 100) |
109
+
110
+ ### Exceptions
111
+
112
+ - `PGWAuthError` — invalid credentials or expired session
113
+ - `PGWConnectionError` — network or portal issues
114
+ - `PGWError` — base exception class
@@ -0,0 +1,100 @@
1
+ # pgw-api
2
+
3
+ Python API client for [Philadelphia Gas Works (PGW)](https://www.pgworks.com/). Fetches natural gas usage data (monthly, daily, and hourly) from the PGW customer portal.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install pgw-api
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ import asyncio
15
+ import aiohttp
16
+ from pgw_api import PGWApiClient
17
+
18
+ async def main():
19
+ client = PGWApiClient("your-email@example.com", "your-password")
20
+
21
+ async with aiohttp.ClientSession(cookie_jar=aiohttp.CookieJar()) as session:
22
+ usage = await client.async_get_usage(session)
23
+
24
+ for entry in usage:
25
+ print(f"{entry.month:%B %Y}: {entry.ccf} CCF ({entry.cf} ft³)")
26
+ if entry.period_start and entry.period_end:
27
+ print(f" Period: {entry.period_start} to {entry.period_end}")
28
+
29
+ asyncio.run(main())
30
+ ```
31
+
32
+ ## API
33
+
34
+ ### `PGWApiClient(username, password)`
35
+
36
+ Creates a client instance with PGW portal credentials.
37
+
38
+ ### `await client.async_get_usage(session)`
39
+
40
+ Authenticates and returns a list of `GasUsage` objects sorted by month (newest first).
41
+
42
+ ### `await client.async_get_daily_usage(session, start, end)`
43
+
44
+ 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.
45
+
46
+ ```python
47
+ from datetime import date
48
+
49
+ daily = await client.async_get_daily_usage(session, date(2024, 1, 1), date(2024, 1, 31))
50
+ for entry in daily:
51
+ print(f"{entry.date}: {entry.ccf} CCF")
52
+ ```
53
+
54
+ ### `await client.async_get_hourly_usage(session, usage_date)`
55
+
56
+ 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.
57
+
58
+ ```python
59
+ from datetime import date
60
+
61
+ hourly = await client.async_get_hourly_usage(session, date(2024, 1, 15))
62
+ for entry in hourly:
63
+ print(f"{entry.timestamp}: {entry.ccf} CCF")
64
+ ```
65
+
66
+ ### `await client.async_validate_credentials(session)`
67
+
68
+ Validates credentials without fetching usage data. Returns `True` or raises `PGWAuthError`.
69
+
70
+ ### `GasUsage`
71
+
72
+ | Property | Type | Description |
73
+ |----------|------|-------------|
74
+ | `month` | `date` | First of the billing month |
75
+ | `ccf` | `float` | Usage in hundreds of cubic feet |
76
+ | `cf` | `float` | Usage in cubic feet (CCF × 100) |
77
+ | `period_start` | `date \| None` | Meter read start date |
78
+ | `period_end` | `date \| None` | Meter read end date |
79
+
80
+ ### `DailyGasUsage`
81
+
82
+ | Property | Type | Description |
83
+ |----------|------|-------------|
84
+ | `date` | `date` | Usage date |
85
+ | `ccf` | `float` | Usage in hundreds of cubic feet |
86
+ | `cf` | `float` | Usage in cubic feet (CCF × 100) |
87
+
88
+ ### `HourlyGasUsage`
89
+
90
+ | Property | Type | Description |
91
+ |----------|------|-------------|
92
+ | `timestamp` | `datetime` | Usage timestamp |
93
+ | `ccf` | `float` | Usage in hundreds of cubic feet |
94
+ | `cf` | `float` | Usage in cubic feet (CCF × 100) |
95
+
96
+ ### Exceptions
97
+
98
+ - `PGWAuthError` — invalid credentials or expired session
99
+ - `PGWConnectionError` — network or portal issues
100
+ - `PGWError` — base exception class
@@ -2,10 +2,13 @@
2
2
 
3
3
  from .client import PGWApiClient
4
4
  from .exceptions import PGWAuthError, PGWConnectionError, PGWError
5
- from .models import GasUsage
5
+ from .models import BillingSummary, DailyGasUsage, GasUsage, HourlyGasUsage
6
6
 
7
7
  __all__ = [
8
+ "BillingSummary",
9
+ "DailyGasUsage",
8
10
  "GasUsage",
11
+ "HourlyGasUsage",
9
12
  "PGWApiClient",
10
13
  "PGWAuthError",
11
14
  "PGWConnectionError",