python-eia 0.2.0__tar.gz → 0.2.1__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.
Files changed (24) hide show
  1. {python_eia-0.2.0 → python_eia-0.2.1}/PKG-INFO +1 -1
  2. {python_eia-0.2.0 → python_eia-0.2.1}/pyproject.toml +1 -1
  3. python_eia-0.2.1/skills/eia/SKILL.md +176 -0
  4. {python_eia-0.2.0 → python_eia-0.2.1}/.github/workflows/publish-to-pypi.yml +0 -0
  5. {python_eia-0.2.0 → python_eia-0.2.1}/.github/workflows/publish.yml +0 -0
  6. {python_eia-0.2.0 → python_eia-0.2.1}/.gitignore +0 -0
  7. {python_eia-0.2.0 → python_eia-0.2.1}/README.md +0 -0
  8. {python_eia-0.2.0 → python_eia-0.2.1/eia/.agents}/skills/eia/SKILL.md +0 -0
  9. {python_eia-0.2.0 → python_eia-0.2.1}/eia/__init__.py +0 -0
  10. {python_eia-0.2.0 → python_eia-0.2.1}/eia/cli/__init__.py +0 -0
  11. {python_eia-0.2.0 → python_eia-0.2.1}/eia/cli/_output.py +0 -0
  12. {python_eia-0.2.0 → python_eia-0.2.1}/eia/cli/app.py +0 -0
  13. {python_eia-0.2.0 → python_eia-0.2.1}/eia/cli/config.py +0 -0
  14. {python_eia-0.2.0 → python_eia-0.2.1}/eia/cli/config_cmd.py +0 -0
  15. {python_eia-0.2.0 → python_eia-0.2.1}/eia/cli/exec_cmd.py +0 -0
  16. {python_eia-0.2.0 → python_eia-0.2.1}/eia/cli/facets_cmd.py +0 -0
  17. {python_eia-0.2.0 → python_eia-0.2.1}/eia/cli/get_cmd.py +0 -0
  18. {python_eia-0.2.0 → python_eia-0.2.1}/eia/cli/meta_cmd.py +0 -0
  19. {python_eia-0.2.0 → python_eia-0.2.1}/eia/cli/routes_cmd.py +0 -0
  20. {python_eia-0.2.0 → python_eia-0.2.1}/eia/client.py +0 -0
  21. {python_eia-0.2.0 → python_eia-0.2.1}/examples/1_Generic/fuel-type-data/1_Download.ipynb +0 -0
  22. {python_eia-0.2.0 → python_eia-0.2.1}/examples/1_Generic/fuel-type-data/2_Analysis.ipynb +0 -0
  23. {python_eia-0.2.0 → python_eia-0.2.1}/examples/1_Generic/steps/1_Download.ipynb +0 -0
  24. {python_eia-0.2.0 → python_eia-0.2.1}/examples/1_Generic/steps/2_Analysis.ipynb +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-eia
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A Python client for the U.S. Energy Information Administration (EIA) API v2
5
5
  Project-URL: Homepage, https://github.com/datons/python-eia
6
6
  Project-URL: Repository, https://github.com/datons/python-eia.git
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "python-eia"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "A Python client for the U.S. Energy Information Administration (EIA) API v2"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -0,0 +1,176 @@
1
+ ---
2
+ name: eia
3
+ description: Query U.S. energy data (EIA API v2). Use when the user asks about U.S. electricity, petroleum, natural gas, or coal data from the EIA.
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # EIA Data Assistant
8
+
9
+ You have access to the `python-eia` CLI and library for querying the U.S. Energy Information Administration (EIA) API v2.
10
+
11
+ The EIA API is a **route-based tree**. You navigate routes to find data endpoints, then query them with facet filters and frequency options.
12
+
13
+ ## CLI Reference
14
+
15
+ ### Explore the API tree
16
+
17
+ ```bash
18
+ # Top-level routes
19
+ eia routes
20
+
21
+ # Navigate deeper
22
+ eia routes electricity
23
+ eia routes electricity/rto
24
+ eia routes electricity/rto/fuel-type-data # Error if leaf — use 'eia meta' instead
25
+ ```
26
+
27
+ ### Inspect a data endpoint
28
+
29
+ ```bash
30
+ # Show facets, frequencies, and data columns
31
+ eia meta electricity/rto/fuel-type-data
32
+ eia meta petroleum/pri/spt
33
+ eia meta natural-gas/pri/sum
34
+ ```
35
+
36
+ ### List facet values
37
+
38
+ ```bash
39
+ # List all values for a facet
40
+ eia facets electricity/rto/fuel-type-data respondent
41
+ eia facets electricity/rto/fuel-type-data fueltype
42
+ eia facets petroleum/pri/spt series --format csv
43
+ ```
44
+
45
+ ### Fetch data
46
+
47
+ ```bash
48
+ # Basic query
49
+ eia get electricity/rto/fuel-type-data \
50
+ --start 2024-06-01 --end 2024-06-08 \
51
+ --frequency hourly \
52
+ --facet respondent=CISO \
53
+ --data value
54
+
55
+ # Multiple facet values (repeat --facet)
56
+ eia get electricity/retail-sales \
57
+ --start 2024-01-01 --end 2024-12-31 \
58
+ --facet stateid=CA --facet sectorid=RES --facet sectorid=COM \
59
+ --data revenue --data sales
60
+
61
+ # Export to CSV
62
+ eia get petroleum/pri/spt --start 2024-01-01 --end 2024-06-01 \
63
+ --format csv --output prices.csv
64
+
65
+ # Sort
66
+ eia get electricity/rto/fuel-type-data \
67
+ --start 2024-06-01 --end 2024-06-02 \
68
+ --frequency hourly --facet respondent=CISO --data value \
69
+ --sort period --sort-dir desc
70
+ ```
71
+
72
+ ### Fetch + eval pandas expression
73
+
74
+ ```bash
75
+ # Descriptive stats
76
+ eia exec electricity/rto/fuel-type-data \
77
+ --start 2024-06-01 --end 2024-06-08 \
78
+ --frequency hourly --facet respondent=CISO --data value \
79
+ -x "df.describe()"
80
+
81
+ # Group by fuel type
82
+ eia exec electricity/rto/fuel-type-data \
83
+ --start 2024-06-01 --end 2024-06-08 \
84
+ --frequency hourly --facet respondent=CISO --data value \
85
+ -x "df.groupby('fueltype')['value'].mean()"
86
+
87
+ # Daily aggregation
88
+ eia exec natural-gas/pri/sum \
89
+ --start 2024-01-01 --end 2024-06-01 \
90
+ -x "df.groupby('process')['value'].mean().sort_values(ascending=False)"
91
+ ```
92
+
93
+ ### Output options (all commands)
94
+
95
+ ```
96
+ --format table|csv|json (default: table)
97
+ --output file.csv (write to file instead of stdout)
98
+ ```
99
+
100
+ ## Common Routes
101
+
102
+ | Route | Description |
103
+ |-------|-------------|
104
+ | `electricity/rto/fuel-type-data` | Real-time grid generation by fuel type |
105
+ | `electricity/rto/region-data` | Real-time grid demand/generation by region |
106
+ | `electricity/rto/interchange-data` | Real-time interchange between regions |
107
+ | `electricity/retail-sales` | Retail electricity sales (monthly/annual) |
108
+ | `electricity/electric-power-operational-data` | Power plant operational data |
109
+ | `petroleum/pri/spt` | Spot petroleum prices (crude, gasoline, etc.) |
110
+ | `petroleum/sum/sndw` | Weekly petroleum supply/demand |
111
+ | `natural-gas/pri/sum` | Natural gas prices summary |
112
+ | `natural-gas/sum/lsum` | Natural gas supply/demand summary |
113
+ | `coal/shipments/receipts` | Coal shipments and receipts |
114
+ | `total-energy/data` | Total energy overview (monthly/annual) |
115
+
116
+ Use `eia routes` to discover more. Use `eia meta <route>` to see exact facets and frequencies.
117
+
118
+ ## Facet Conventions
119
+
120
+ - **Format**: `--facet key=value` (repeatable)
121
+ - **Multiple values**: repeat the flag — `--facet sectorid=RES --facet sectorid=COM`
122
+ - **Common facets**: `respondent` (grid operator), `fueltype`, `stateid`, `sectorid`, `series`
123
+ - Each endpoint has different facets — use `eia meta` and `eia facets` to discover them
124
+
125
+ ## Python Library
126
+
127
+ ```python
128
+ from eia import EIAClient
129
+
130
+ client = EIAClient() # reads config file, then EIA_API_KEY env var
131
+
132
+ # Navigate the route tree
133
+ route = client.route("electricity/rto/fuel-type-data")
134
+ route.routes # Dict of child routes (if branch node)
135
+ route.data # Data object (if leaf node)
136
+
137
+ # Inspect metadata
138
+ route.data.facets # FacetContainer with attribute access
139
+ route.data.frequencies # List[FrequencyInfo]
140
+ route.data.data_columns # Dict[str, DataColumnInfo]
141
+ route.data.facets.respondent.get_values() # List[FacetValue]
142
+
143
+ # Direct access to a data endpoint
144
+ data = client.get_data_endpoint("electricity/rto/fuel-type-data")
145
+
146
+ # Fetch data as DataFrame
147
+ df = data.get(
148
+ data_columns=["value"],
149
+ facets={"respondent": "CISO"},
150
+ frequency="hourly",
151
+ start="2024-01-01",
152
+ end="2024-01-31",
153
+ sort=[{"column": "period", "direction": "desc"}],
154
+ )
155
+ ```
156
+
157
+ ## Configuration
158
+
159
+ ```bash
160
+ # Store your API key persistently (recommended)
161
+ eia config set api-key YOUR_KEY
162
+
163
+ # Verify it's stored
164
+ eia config get api-key
165
+ ```
166
+
167
+ The config file is stored at `~/.config/eia/config.toml`.
168
+
169
+ ## Key Conventions
170
+
171
+ - The `period` column is auto-converted to datetime (UTC for non-local frequencies)
172
+ - The `value` column is auto-converted to numeric
173
+ - Pagination is automatic by default (fetches all pages)
174
+ - API key resolution: config file (`~/.config/eia/config.toml`) > `EIA_API_KEY` env var
175
+ - API page limit is 5000 rows per request
176
+ - Custom exception: `EIAError` (includes HTTP status code and API error code)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes