ercot-api 0.1.0__py3-none-any.whl

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.
ercot_api/__init__.py ADDED
@@ -0,0 +1,69 @@
1
+ """ercot_api: thin urllib client for the ERCOT Public API.
2
+
3
+ Credentials come from registering on the ERCOT Public API Portal
4
+ (https://apiexplorer.ercot.com): you get a subscription key, and a bearer token is
5
+ obtained from the ERCOT B2C sign-in flow for your registered account. Both are passed
6
+ in as plain strings; this package never stores them.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import argparse
11
+ import json
12
+ import urllib.parse
13
+ import urllib.request
14
+
15
+ __version__ = "0.1.0"
16
+ __all__ = ["ErcotClient", "BASE_URL", "main", "__version__"]
17
+
18
+ BASE_URL = "https://api.ercot.com/api/public-reports"
19
+
20
+
21
+ class ErcotClient:
22
+ """Call ERCOT public report endpoints, e.g. client.get("np6-905-cd/spp_node_zone_hub")."""
23
+
24
+ def __init__(self, subscription_key: str, bearer: str, base_url: str = BASE_URL, timeout: float = 30.0,
25
+ opener=None):
26
+ self.subscription_key = subscription_key
27
+ self.bearer = bearer
28
+ self.base_url = base_url.rstrip("/")
29
+ self.timeout = timeout
30
+ self._open = opener or urllib.request.urlopen
31
+
32
+ def build_request(self, report_id: str, **params) -> urllib.request.Request:
33
+ url = f"{self.base_url}/{report_id.strip('/')}"
34
+ clean = {k: v for k, v in params.items() if v is not None}
35
+ if clean:
36
+ url += "?" + urllib.parse.urlencode(clean)
37
+ return urllib.request.Request(url, headers={
38
+ "Ocp-Apim-Subscription-Key": self.subscription_key,
39
+ "Authorization": f"Bearer {self.bearer}",
40
+ "Accept": "application/json",
41
+ })
42
+
43
+ def get(self, report_id: str, **params):
44
+ req = self.build_request(report_id, **params)
45
+ with self._open(req, timeout=self.timeout) as resp:
46
+ return json.loads(resp.read().decode("utf-8"))
47
+
48
+
49
+ def main(argv=None) -> int:
50
+ p = argparse.ArgumentParser(prog="ercot-api", description=__doc__,
51
+ formatter_class=argparse.RawDescriptionHelpFormatter)
52
+ p.add_argument("--version", action="version", version=__version__)
53
+ p.add_argument("report_id", nargs="?", help="e.g. np6-905-cd/spp_node_zone_hub")
54
+ p.add_argument("--key", help="Ocp-Apim-Subscription-Key from the ERCOT Public API Portal")
55
+ p.add_argument("--bearer", help="bearer token from ERCOT sign-in")
56
+ p.add_argument("--param", action="append", default=[], metavar="K=V", help="query parameter")
57
+ a = p.parse_args(argv)
58
+ if not a.report_id:
59
+ p.print_help()
60
+ return 0
61
+ if not (a.key and a.bearer):
62
+ p.error("--key and --bearer are required (register at https://apiexplorer.ercot.com)")
63
+ params = dict(kv.split("=", 1) for kv in a.param)
64
+ print(json.dumps(ErcotClient(a.key, a.bearer).get(a.report_id, **params), indent=2))
65
+ return 0
66
+
67
+
68
+ if __name__ == "__main__":
69
+ raise SystemExit(main())
ercot_api/__main__.py ADDED
@@ -0,0 +1,3 @@
1
+ from . import main
2
+
3
+ raise SystemExit(main())
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.4
2
+ Name: ercot-api
3
+ Version: 0.1.0
4
+ Summary: Minimal client skeleton for the ERCOT Public API (api.ercot.com/api/public-reports)
5
+ Author-email: BitSquad LLC <admin@megawattland.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://megawattland.com
8
+ Project-URL: Repository, https://github.com/chutch62416-netizen/vault
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Dynamic: license-file
17
+
18
+ # ercot-api
19
+
20
+ Minimal client skeleton for the ERCOT Public API (api.ercot.com/api/public-reports)
21
+
22
+ ## Credentials
23
+
24
+ Register at the ERCOT Public API Portal (https://apiexplorer.ercot.com). Registration gives you
25
+ an `Ocp-Apim-Subscription-Key`; the bearer token comes from ERCOT's sign-in flow for that account.
26
+ This package does not store or obtain credentials for you.
27
+
28
+ ## Usage
29
+
30
+ ```python
31
+ from ercot_api import ErcotClient
32
+ c = ErcotClient(subscription_key="...", bearer="...")
33
+ c.get("np6-905-cd/spp_node_zone_hub", deliveryDateFrom="2026-01-01", size=100)
34
+ ```
35
+
36
+ ```
37
+ ercot-api --help
38
+ ercot-api np6-905-cd/spp_node_zone_hub --key KEY --bearer TOKEN --param size=10
39
+ ```
40
+
41
+ Unofficial; not affiliated with ERCOT.
42
+
43
+ Maintained by [BitSquad LLC / MegawattLand](https://megawattland.com). MIT license. Source: https://github.com/chutch62416-netizen/vault
@@ -0,0 +1,8 @@
1
+ ercot_api/__init__.py,sha256=WghLayH1KMhlAFciH7acPlMB3PWwzZru4r6rt_q5Gk0,2821
2
+ ercot_api/__main__.py,sha256=BHLi_-4Bx1gsZn-z6x7wECPn1YTxdc74y0deRea9FzY,45
3
+ ercot_api-0.1.0.dist-info/licenses/LICENSE,sha256=PKnyP0njONZraEkwKoS7B021snnKAl2lI3AenCo-RVM,1069
4
+ ercot_api-0.1.0.dist-info/METADATA,sha256=GJu1E2Vjb8wOX8Ai10Z-U1tzvRFgYZBIF-Q4ONrPxyY,1471
5
+ ercot_api-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
6
+ ercot_api-0.1.0.dist-info/entry_points.txt,sha256=KxSJMPeV3s3ks3ropVL9YYOXH-NxfwId80UhVBl6Mzg,45
7
+ ercot_api-0.1.0.dist-info/top_level.txt,sha256=cJa03q3d55L1Qca4_2Ph1kdCXFHcWoDhMZ7Qwl9chto,10
8
+ ercot_api-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ercot-api = ercot_api:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BitSquad LLC
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.
@@ -0,0 +1 @@
1
+ ercot_api