openelectricity 0.1.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.
@@ -0,0 +1,11 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+ .envrc
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 OpenElectricity Contributors
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,35 @@
1
+ .PHONY: install format lint test clean build publish venv
2
+
3
+ VENV_DIR := .venv
4
+ PYTHON := $(VENV_DIR)/bin/python
5
+ UV := $(VENV_DIR)/bin/uv
6
+
7
+ venv:
8
+ python -m venv $(VENV_DIR)
9
+ $(PYTHON) -m pip install uv
10
+
11
+ install: venv
12
+ $(UV) pip install -e ".[dev]"
13
+
14
+ format:
15
+ $(PYTHON) -m ruff format .
16
+
17
+ lint:
18
+ $(PYTHON) -m ruff check .
19
+ $(PYTHON) -m pyright
20
+
21
+ test:
22
+ $(PYTHON) -m pytest
23
+
24
+ clean:
25
+ rm -rf build/
26
+ rm -rf dist/
27
+ rm -rf *.egg-info
28
+ find . -type d -name __pycache__ -exec rm -rf {} +
29
+ rm -rf $(VENV_DIR)
30
+
31
+ build: clean venv install
32
+ $(PYTHON) -m build
33
+
34
+ publish: build
35
+ $(PYTHON) -m twine upload dist/*
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: openelectricity
3
+ Version: 0.1.0
4
+ Summary: OpenElectricity Python Client
5
+ Author: OpenElectricity Contributors
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Requires-Python: >=3.12
15
+ Requires-Dist: httpx>=0.28.1
16
+ Requires-Dist: pydantic>=2.10.3
17
+ Provides-Extra: dev
18
+ Requires-Dist: build>=1.0.3; extra == 'dev'
19
+ Requires-Dist: hatch>=1.14.0; extra == 'dev'
20
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
21
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
22
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
23
+ Requires-Dist: ruff>=0.8.3; extra == 'dev'
24
+ Requires-Dist: twine>=4.0.2; extra == 'dev'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # OpenElectricity Python SDK
28
+
29
+ A Python SDK for interacting with the OpenElectricity API. This SDK provides both synchronous and asynchronous clients for accessing OpenElectricity data.
30
+
31
+ ## Features
32
+
33
+ - Synchronous and asynchronous API clients
34
+ - Type hints for better IDE support
35
+ - Automatic request retries and error handling
36
+ - Context manager support for proper resource cleanup
37
+ - Modern Python (3.12+) with full type annotations
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install openelectricity
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ ```python
48
+ from openelectricity import Client
49
+
50
+ # Using environment variable OPENELECTRICITY_API_KEY
51
+ with Client() as client:
52
+ # API calls will be implemented here
53
+ pass
54
+
55
+ # Or provide API key directly
56
+ client = Client(api_key="your-api-key")
57
+ ```
58
+
59
+ For async usage:
60
+
61
+ ```python
62
+ from openelectricity import AsyncClient
63
+ import asyncio
64
+
65
+ async def main():
66
+ async with AsyncClient() as client:
67
+ # API calls will be implemented here
68
+ pass
69
+
70
+ asyncio.run(main())
71
+ ```
72
+
73
+ ## Documentation
74
+
75
+ For detailed usage instructions and API reference, see the [documentation](docs/usage.md).
76
+
77
+ ## Development
78
+
79
+ 1. Clone the repository
80
+ 2. Install development dependencies:
81
+
82
+ ```bash
83
+ make install
84
+ ```
85
+
86
+ 3. Run tests:
87
+
88
+ ```bash
89
+ make test
90
+ ```
91
+
92
+ 4. Format code:
93
+
94
+ ```bash
95
+ make format
96
+ ```
97
+
98
+ 5. Run linters:
99
+ ```bash
100
+ make lint
101
+ ```
102
+
103
+ ## License
104
+
105
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,79 @@
1
+ # OpenElectricity Python SDK
2
+
3
+ A Python SDK for interacting with the OpenElectricity API. This SDK provides both synchronous and asynchronous clients for accessing OpenElectricity data.
4
+
5
+ ## Features
6
+
7
+ - Synchronous and asynchronous API clients
8
+ - Type hints for better IDE support
9
+ - Automatic request retries and error handling
10
+ - Context manager support for proper resource cleanup
11
+ - Modern Python (3.12+) with full type annotations
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install openelectricity
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```python
22
+ from openelectricity import Client
23
+
24
+ # Using environment variable OPENELECTRICITY_API_KEY
25
+ with Client() as client:
26
+ # API calls will be implemented here
27
+ pass
28
+
29
+ # Or provide API key directly
30
+ client = Client(api_key="your-api-key")
31
+ ```
32
+
33
+ For async usage:
34
+
35
+ ```python
36
+ from openelectricity import AsyncClient
37
+ import asyncio
38
+
39
+ async def main():
40
+ async with AsyncClient() as client:
41
+ # API calls will be implemented here
42
+ pass
43
+
44
+ asyncio.run(main())
45
+ ```
46
+
47
+ ## Documentation
48
+
49
+ For detailed usage instructions and API reference, see the [documentation](docs/usage.md).
50
+
51
+ ## Development
52
+
53
+ 1. Clone the repository
54
+ 2. Install development dependencies:
55
+
56
+ ```bash
57
+ make install
58
+ ```
59
+
60
+ 3. Run tests:
61
+
62
+ ```bash
63
+ make test
64
+ ```
65
+
66
+ 4. Format code:
67
+
68
+ ```bash
69
+ make format
70
+ ```
71
+
72
+ 5. Run linters:
73
+ ```bash
74
+ make lint
75
+ ```
76
+
77
+ ## License
78
+
79
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1 @@
1
+ {"openapi":"3.1.0","info":{"title":"OpenElectricity - v4.0","version":"v4.0"},"paths":{"/v4/facility/":{"get":{"tags":["Facilities"],"summary":"Get Facilities","description":"Get a list of all facilities","operationId":"get_facilities_v4_facility__get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIV4ResponseSchema"}}}}}}},"/v4/facility/au/{network_id}/{station_code}":{"get":{"tags":["Facilities"],"summary":"Get Station Information","description":"Get a single station by code","operationId":"Get_station_information_v4_facility_au__network_id___station_code__get","parameters":[{"name":"network_id","in":"path","required":true,"schema":{"type":"string","title":"Network Id"}},{"name":"station_code","in":"path","required":true,"schema":{"type":"string","title":"Station Code"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIV4ResponseSchema"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v4/fueltechs":{"get":{"tags":["Core"],"summary":"Fueltechs","description":"Get all fueltechs","operationId":"fueltechs_v4_fueltechs_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/FueltechSchema"},"type":"array","title":"Response Fueltechs V4 Fueltechs Get"}}}}}}},"/v4/intervals":{"get":{"tags":["Core"],"summary":"Intervals","description":"Get all intervals","operationId":"intervals_v4_intervals_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/TimeInterval"},"type":"array","title":"Response Intervals V4 Intervals Get"}}}}}}},"/v4/me":{"get":{"tags":["User"],"summary":"Get User Me","description":"Get the current user","operationId":"get_user_me_v4_me_get","requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/OpenNEMUser-Input"},{"type":"null"}],"title":"User"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenNEMUser-Output"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/v4/milestones/history/{record_id}":{"get":{"tags":["Milestones","Milestones"],"summary":"Get Milestone By Record Id","description":"Get a single milestone","operationId":"get_milestone_by_record_id_v4_milestones_history__record_id__get","parameters":[{"name":"record_id","in":"path","required":true,"schema":{"type":"string","title":"Record Id"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":1000,"title":"Limit"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer","default":1,"title":"Page"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIV4ResponseSchema"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v4/milestones/instance/{instance_id}":{"get":{"tags":["Milestones","Milestones"],"summary":"Get Milestone","description":"Get a single milestone","operationId":"get_milestone_v4_milestones_instance__instance_id__get","parameters":[{"name":"instance_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Instance Id"}},{"name":"include_history","in":"query","required":false,"schema":{"type":"boolean","description":"Include historical milestone records","default":false,"title":"Include History"},"description":"Include historical milestone records"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIV4ResponseSchema"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v4/milestones/metadata":{"get":{"tags":["Milestones","Milestones"],"summary":"Get Milestone Metadata","description":"Get metadata for milestones","operationId":"get_milestone_metadata_v4_milestones_metadata_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MilestoneMetadataSchema"}}}}}}},"/v4/milestones/record_id":{"get":{"tags":["Milestones","Milestones"],"summary":"Api Get Milestone Record Ids","description":"Get a list of milestone record ids with the most recent record for each record_id","operationId":"api_get_milestone_record_ids_v4_milestones_record_id_get","parameters":[{"name":"record_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Filter by record_id","title":"Record Id"},"description":"Filter by record_id"},{"name":"date_start","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Date Start"}},{"name":"date_end","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Date End"}},{"name":"aggregate","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/MilestoneAggregate"},{"type":"null"}],"title":"Aggregate"}},{"name":"milestone_type","in":"query","required":false,"schema":{"anyOf":[{"type":"array","items":{"$ref":"#/components/schemas/MilestoneType"}},{"type":"null"}],"description":"Milestone type filter","title":"Milestone Type"},"description":"Milestone type filter"},{"name":"fueltech_id","in":"query","required":false,"schema":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}],"title":"Fueltech Id"}},{"name":"network","in":"query","required":false,"schema":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}],"title":"Network"}},{"name":"network_region","in":"query","required":false,"schema":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}],"title":"Network Region"}},{"name":"significance","in":"query","required":false,"schema":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"Significance filter","title":"Significance"},"description":"Significance filter"},{"name":"significance_min","in":"query","required":false,"schema":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"Significance minimum filter","title":"Significance Min"},"description":"Significance minimum filter"},{"name":"significance_max","in":"query","required":false,"schema":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"Significance maximum filter","title":"Significance Max"},"description":"Significance maximum filter"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIV4ResponseSchema"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v4/milestones/records":{"get":{"tags":["Milestones","Milestones"],"summary":"Get Milestones","description":"Get milestones","operationId":"get_milestones_v4_milestones_records_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":100,"title":"Limit"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer","default":1,"title":"Page"}},{"name":"date_start","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Date Start"}},{"name":"date_end","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Date End"}},{"name":"aggregate","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/MilestoneAggregate"},{"type":"null"}],"title":"Aggregate"}},{"name":"milestone_type","in":"query","required":false,"schema":{"anyOf":[{"type":"array","items":{"$ref":"#/components/schemas/MilestoneType"}},{"type":"null"}],"description":"Milestone type filter","title":"Milestone Type"},"description":"Milestone type filter"},{"name":"fueltech_id","in":"query","required":false,"schema":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}],"title":"Fueltech Id"}},{"name":"network","in":"query","required":false,"schema":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}],"title":"Network"}},{"name":"record_filter","in":"query","required":false,"schema":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}],"description":"Network filter - specify network or network_region ids","title":"Record Filter"},"description":"Network filter - specify network or network_region ids"},{"name":"network_region","in":"query","required":false,"schema":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null"}],"title":"Network Region"}},{"name":"significance","in":"query","required":false,"schema":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"Significance filter","title":"Significance"},"description":"Significance filter"},{"name":"significance_min","in":"query","required":false,"schema":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"Significance minimum filter","title":"Significance Min"},"description":"Significance minimum filter"},{"name":"significance_max","in":"query","required":false,"schema":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"Significance maximum filter","title":"Significance Max"},"description":"Significance maximum filter"},{"name":"record_id_filter","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Filter by record_id - supports wildcards","title":"Record Id Filter"},"description":"Filter by record_id - supports wildcards"},{"name":"period","in":"query","required":false,"schema":{"anyOf":[{"type":"array","items":{"$ref":"#/components/schemas/MilestonePeriod"}},{"type":"null"}],"description":"Period filter","title":"Period"},"description":"Period filter"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIV4ResponseSchema"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v4/networks":{"get":{"tags":["Core"],"summary":"Get Networks","description":"Get networks","operationId":"get_networks_v4_networks_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/APINetworkSchema"},"type":"array","title":"Response Get Networks V4 Networks Get"}}}}}}},"/v4/networks/regions":{"get":{"tags":["Core"],"summary":"Get Network Regions","description":"Get network regions","operationId":"get_network_regions_v4_networks_regions_get","parameters":[{"name":"network_code","in":"query","required":true,"schema":{"type":"string","description":"Network code","title":"Network Code"},"description":"Network code"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/APINetworkRegion"},"title":"Response Get Network Regions V4 Networks Regions Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v4/periods":{"get":{"tags":["Core"],"summary":"Periods","description":"Get all periods","operationId":"periods_v4_periods_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/TimePeriod"},"type":"array","title":"Response Periods V4 Periods Get"}}}}}}},"/v4/units":{"get":{"tags":["Core"],"summary":"Units","description":"Get all units","operationId":"units_v4_units_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/UnitDefinition"},"type":"array","title":"Response Units V4 Units Get"}}}}}}}},"components":{"schemas":{"APINetworkRegion":{"properties":{"code":{"type":"string","title":"Code"},"timezone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Timezone"}},"type":"object","required":["code"],"title":"APINetworkRegion"},"APINetworkSchema":{"properties":{"code":{"type":"string","title":"Code"},"country":{"type":"string","title":"Country"},"label":{"type":"string","title":"Label"},"regions":{"anyOf":[{"items":{"$ref":"#/components/schemas/APINetworkRegion"},"type":"array"},{"type":"null"}],"title":"Regions"},"timezone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Timezone","description":"Network timezone"},"interval_size":{"type":"integer","title":"Interval Size","description":"Size of network interval in minutes"}},"type":"object","required":["code","country","label","interval_size"],"title":"APINetworkSchema"},"APIV4ResponseSchema":{"properties":{"version":{"type":"string","title":"Version"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"success":{"type":"boolean","title":"Success","default":true},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"},"data":{"items":{},"type":"array","title":"Data","default":[]},"total_records":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Total Records"}},"type":"object","title":"APIV4ResponseSchema"},"FueltechSchema":{"properties":{"code":{"type":"string","title":"Code"},"label":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Label"},"renewable":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Renewable"}},"type":"object","required":["code"],"title":"FueltechSchema"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"MilestoneAggregate":{"type":"string","enum":["low","high"],"title":"MilestoneAggregate","description":"Enum representing different types of aggregates for milestones in the OpenNEM project.\n\nThese aggregates are used to summarise data over different time intervals.\n\nThis determines the type of aggregation that is applied to the data."},"MilestoneFueltechGrouping":{"type":"string","enum":["battery_charging","battery_discharging","bioenergy","coal","demand","distillate","gas","hydro","pumps","solar","wind","renewables","fossils"],"title":"MilestoneFueltechGrouping","description":"Enum representing different fuel technology groupings for milestones in the OpenNEM project.\n\nThese groupings are used to categorise and analyse energy production and consumption\nacross various technologies in the Australian electricity system."},"MilestoneMetadataSchema":{"properties":{"aggregates":{"items":{"$ref":"#/components/schemas/MilestoneAggregate"},"type":"array","title":"Aggregates"},"milestone_type":{"items":{"$ref":"#/components/schemas/MilestoneType"},"type":"array","title":"Milestone Type"},"periods":{"items":{"$ref":"#/components/schemas/MilestonePeriod"},"type":"array","title":"Periods"},"units":{"additionalProperties":{"$ref":"#/components/schemas/MilestoneUnitSchema"},"type":"object","title":"Units"},"fueltechs":{"items":{"$ref":"#/components/schemas/MilestoneFueltechGrouping"},"type":"array","title":"Fueltechs"},"networks":{"items":{"$ref":"#/components/schemas/NetworkSchema"},"type":"array","title":"Networks"},"network_regions":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Network Regions"}},"type":"object","required":["aggregates","milestone_type","periods","units","fueltechs","networks"],"title":"MilestoneMetadataSchema","description":"Metadata schema for a milestone"},"MilestonePeriod":{"type":"string","enum":["interval","day","7d","month","quarter","season","year","financial_year"],"title":"MilestonePeriod","description":"Enum representing different periods for milestones in the OpenNEM project.\n\nThese periods are used to aggregate data over different time intervals.\n\nThis determines the window of time that a milestone covers. ie. the start and end dates in queries"},"MilestoneType":{"type":"string","enum":["power","energy","demand","price","market_value","emissions","proportion"],"title":"MilestoneType","description":"Enum representing different types of milestones in the OpenNEM project.\n\nThese types are used to categorise and analyse energy production and consumption\nacross various technologies in the Australian electricity system.\n\nThis determines the source of data and query for the milestone."},"MilestoneUnitSchema":{"properties":{"name":{"type":"string","title":"Name"},"label":{"type":"string","title":"Label"},"unit":{"type":"string","title":"Unit"},"output_format":{"type":"string","title":"Output Format"}},"type":"object","required":["name","label","unit","output_format"],"title":"MilestoneUnitSchema","description":""},"NetworkSchema":{"properties":{"code":{"type":"string","title":"Code"},"country":{"type":"string","title":"Country"},"label":{"type":"string","title":"Label"},"timezone":{"type":"string","title":"Timezone","description":"Network timezone"},"timezone_database":{"type":"string","title":"Timezone Database","description":"Database timezone format","default":"UTC"},"offset":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Offset","description":"Network time offset in minutes"},"interval_size":{"type":"integer","title":"Interval Size","description":"Size of network interval in minutes"},"interval_size_price":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Interval Size Price"},"interval_shift":{"type":"integer","title":"Interval Shift","default":0},"data_first_seen":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Data First Seen"},"data_last_seen":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Data Last Seen"},"price_first_seen":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Price First Seen"},"interconnector_first_seen":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Interconnector First Seen"},"rooftop_first_seen":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Rooftop First Seen"},"monitor_interval_alert_threshold":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Monitor Interval Alert Threshold"},"subnetworks":{"anyOf":[{"items":{"$ref":"#/components/schemas/NetworkSchema"},"type":"array"},{"type":"null"}],"title":"Subnetworks"},"parent_network":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Network"},"fueltechs":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Fueltechs","description":"Fueltechs provided by this network"},"has_interconnectors":{"type":"boolean","title":"Has Interconnectors","default":false},"regions":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Regions"}},"type":"object","required":["code","country","label","timezone","interval_size"],"title":"NetworkSchema"},"OpenNEMRoles":{"type":"string","enum":["admin","pro","academic","user","anonymous"],"title":"OpenNEMRoles"},"OpenNEMUser-Input":{"properties":{"valid":{"type":"boolean","title":"Valid"},"id":{"type":"string","title":"Id"},"owner_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Owner Id"},"meta":{"anyOf":[{"type":"object"},{"type":"null"}],"title":"Meta","default":{}},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"},"rate_limit":{"anyOf":[{"$ref":"#/components/schemas/OpenNEMUserRateLimit"},{"type":"null"}]},"unkey_meta":{"anyOf":[{"type":"object"},{"type":"null"}],"title":"Unkey Meta"},"clerk_meta":{"anyOf":[{"type":"object"},{"type":"null"}],"title":"Clerk Meta"},"roles":{"items":{"$ref":"#/components/schemas/OpenNEMRoles"},"type":"array","title":"Roles","default":["anonymous"]}},"type":"object","required":["valid","id"],"title":"OpenNEMUser"},"OpenNEMUser-Output":{"properties":{"valid":{"type":"boolean","title":"Valid"},"id":{"type":"string","title":"Id"},"owner_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Owner Id"},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"},"rate_limit":{"anyOf":[{"$ref":"#/components/schemas/OpenNEMUserRateLimit"},{"type":"null"}]},"unkey_meta":{"anyOf":[{"type":"object"},{"type":"null"}],"title":"Unkey Meta"},"clerk_meta":{"anyOf":[{"type":"object"},{"type":"null"}],"title":"Clerk Meta"},"roles":{"items":{"$ref":"#/components/schemas/OpenNEMRoles"},"type":"array","title":"Roles","default":["anonymous"]}},"type":"object","required":["valid","id"],"title":"OpenNEMUser"},"OpenNEMUserRateLimit":{"properties":{"limit":{"type":"integer","title":"Limit"},"remaining":{"type":"integer","title":"Remaining"},"reset":{"anyOf":[{"type":"string","format":"date-time"},{"type":"integer"}],"title":"Reset"}},"type":"object","required":["limit","remaining","reset"],"title":"OpenNEMUserRateLimit"},"TimeInterval":{"properties":{"interval":{"type":"integer","title":"Interval","description":"Interval size in minutes"},"interval_human":{"type":"string","title":"Interval Human","description":"Interval size in human length"},"interval_sql":{"type":"string","title":"Interval Sql"},"trunc":{"type":"string","title":"Trunc"}},"type":"object","required":["interval","interval_human","interval_sql","trunc"],"title":"TimeInterval"},"TimePeriod":{"properties":{"period":{"type":"integer","title":"Period","description":"Period in minutes"},"period_human":{"type":"string","title":"Period Human","description":"Period in human size"},"period_sql":{"type":"string","title":"Period Sql"}},"type":"object","required":["period","period_human","period_sql"],"title":"TimePeriod"},"UnitDefinition":{"properties":{"name":{"type":"string","title":"Name","description":"Name of the unit"},"name_alias":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name Alias","description":"Name alias"},"unit_type":{"type":"string","title":"Unit Type","description":"Type of unit"},"round_to":{"type":"integer","title":"Round To","default":2},"unit":{"type":"string","title":"Unit","description":"Unit abbreviation"},"cast_nulls":{"type":"boolean","title":"Cast Nulls","default":true}},"type":"object","required":["name","unit_type","unit"],"title":"UnitDefinition"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}}}}
@@ -0,0 +1,129 @@
1
+ # OpenElectricity Python SDK Usage
2
+
3
+ The OpenElectricity Python SDK provides a simple interface to interact with the OpenElectricity API. It supports both synchronous and asynchronous operations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install openelectricity
9
+ ```
10
+
11
+ ## Authentication
12
+
13
+ The SDK requires an API key for authentication. You can provide it in two ways:
14
+
15
+ 1. Environment variable:
16
+
17
+ ```bash
18
+ export OPENELECTRICITY_API_KEY="your-api-key"
19
+ ```
20
+
21
+ 2. Directly in code:
22
+
23
+ ```python
24
+ from openelectricity import OEClient
25
+
26
+ client = OEClient(api_key="your-api-key")
27
+ ```
28
+
29
+ ## Synchronous Usage
30
+
31
+ ```python
32
+ from openelectricity import OEClient
33
+
34
+ # Create a client
35
+ client = OEClient()
36
+
37
+ # Use context manager for automatic cleanup
38
+ with OEClient() as client:
39
+ # Get list of networks
40
+ networks = client.get_networks()
41
+ print(f"Found {len(networks)} networks")
42
+
43
+ # Access network information
44
+ for network in networks:
45
+ print(f"Network: {network.label} ({network.code})")
46
+ print(f"Regions: {[r.code for r in network.regions]}")
47
+ ```
48
+
49
+ ## Asynchronous Usage
50
+
51
+ ```python
52
+ from openelectricity import AsyncOEClient
53
+ import asyncio
54
+
55
+ async def main():
56
+ async with AsyncOEClient() as client:
57
+ # Get list of networks
58
+ networks = await client.get_networks()
59
+ print(f"Found {len(networks)} networks")
60
+
61
+ # Access network information
62
+ for network in networks:
63
+ print(f"Network: {network.label} ({network.code})")
64
+ print(f"Regions: {[r.code for r in network.regions]}")
65
+
66
+ # Run the async code
67
+ asyncio.run(main())
68
+ ```
69
+
70
+ ## Network Operations
71
+
72
+ ### List Networks
73
+
74
+ ```python
75
+ # Synchronous
76
+ networks = client.get_networks()
77
+ for network in networks:
78
+ print(f"Network: {network.label} ({network.code})")
79
+ for region in network.regions:
80
+ print(f" Region: {region.code} (Timezone: {region.timezone})")
81
+
82
+ # Asynchronous
83
+ networks = await client.get_networks()
84
+ for network in networks:
85
+ print(f"Network: {network.label} ({network.code})")
86
+ for region in network.regions:
87
+ print(f" Region: {region.code} (Timezone: {region.timezone})")
88
+ ```
89
+
90
+ The `Network` object includes:
91
+
92
+ - `code`: Network code
93
+ - `country`: Country code
94
+ - `label`: Network label/name
95
+ - `regions`: List of regions in the network
96
+ - `timezone`: Network timezone
97
+ - `interval_size`: Size of data intervals in minutes
98
+
99
+ The `NetworkRegion` object includes:
100
+
101
+ - `code`: Region code
102
+ - `timezone`: Region timezone
103
+
104
+ ## Error Handling
105
+
106
+ The SDK provides custom exceptions for error handling:
107
+
108
+ - `OpenElectricityError`: Base exception class
109
+ - `APIError`: Raised when the API returns an error response
110
+
111
+ ```python
112
+ from openelectricity import OEClient, OpenElectricityError, APIError
113
+
114
+ try:
115
+ with OEClient() as client:
116
+ networks = client.get_networks()
117
+ except APIError as e:
118
+ print(f"API Error {e.status_code}: {e.detail}")
119
+ except OpenElectricityError as e:
120
+ print(f"SDK Error: {e}")
121
+ ```
122
+
123
+ ## Configuration
124
+
125
+ You can customize the client by providing a different base URL:
126
+
127
+ ```python
128
+ client = OEClient(base_url="https://api.staging.openelectricity.org.au/v4")
129
+ ```
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env python
2
+ """
3
+ Example script demonstrating how to list networks using the OpenElectricity SDK.
4
+
5
+ This script shows both synchronous and asynchronous usage patterns.
6
+ """
7
+
8
+ import asyncio
9
+ import os
10
+ from typing import NoReturn
11
+
12
+ from openelectricity import OEClient, AsyncOEClient
13
+ from openelectricity.models.networks import Network
14
+
15
+
16
+ def print_network(network: Network) -> None:
17
+ """Print network information in a formatted way."""
18
+ print(f"\nNetwork: {network.label} ({network.code})")
19
+ print(f" Country: {network.country}")
20
+ print(f" Network Timezone: {network.timezone}")
21
+ print(f" Interval Size: {network.interval_size} minutes")
22
+ print(" Regions:")
23
+
24
+ if network.regions:
25
+ for region in network.regions:
26
+ print(f" - {region.code} (Timezone: {region.timezone})")
27
+ else:
28
+ print(" - None")
29
+
30
+
31
+ def sync_example() -> None:
32
+ """Demonstrate synchronous network listing."""
33
+ print("\nSynchronous Example:")
34
+ print("-------------------")
35
+
36
+ with OEClient() as client:
37
+ # Get networks
38
+ networks = client.get_networks()
39
+ print(f"\nFound {len(networks)} networks")
40
+
41
+ for network in networks:
42
+ print_network(network)
43
+
44
+
45
+ async def async_example() -> None:
46
+ """Demonstrate asynchronous network listing."""
47
+ print("\nAsynchronous Example:")
48
+ print("--------------------")
49
+
50
+ async with AsyncOEClient() as client:
51
+ # Get networks
52
+ networks = await client.get_networks()
53
+ print(f"\nFound {len(networks)} networks")
54
+
55
+ for network in networks:
56
+ print_network(network)
57
+
58
+
59
+ def main() -> NoReturn:
60
+ """Run both sync and async examples."""
61
+ if not os.getenv("OPENELECTRICITY_API_KEY"):
62
+ raise ValueError("Please set the OPENELECTRICITY_API_KEY environment variable")
63
+
64
+ # Run sync example
65
+ sync_example()
66
+
67
+ # Run async example
68
+ asyncio.run(async_example())
69
+
70
+
71
+ if __name__ == "__main__":
72
+ main()
@@ -0,0 +1,11 @@
1
+ """
2
+ OpenElectricity Python SDK
3
+
4
+ This package provides a Python client for interacting with the OpenElectricity API.
5
+ """
6
+
7
+ from openelectricity.client import OEClient, AsyncOEClient
8
+
9
+ __version__ = "0.1.0"
10
+
11
+ __all__ = ["OEClient", "AsyncOEClient"]