osmund 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,63 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags: ["v*"]
7
+ pull_request:
8
+ workflow_dispatch:
9
+
10
+ permissions: {}
11
+
12
+ jobs:
13
+ test:
14
+ name: Test
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ contents: read
18
+ steps:
19
+ - uses: actions/checkout@v7
20
+ with:
21
+ persist-credentials: false
22
+ - uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
23
+ - run: uv sync --locked
24
+ - run: uv run ruff check .
25
+ - run: uv run ruff format --check .
26
+ - run: uv run pytest -q
27
+
28
+ build:
29
+ name: Build
30
+ needs: test
31
+ runs-on: ubuntu-latest
32
+ permissions:
33
+ contents: read
34
+ steps:
35
+ - uses: actions/checkout@v7
36
+ with:
37
+ persist-credentials: false
38
+ - uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
39
+ # A version on PyPI matches a tagged release: the tag v1.2.3 publishes 1.2.3, and nothing else.
40
+ - name: The tag is the version
41
+ if: startsWith(github.ref, 'refs/tags/v')
42
+ run: test "v$(uv version --short)" = "$GITHUB_REF_NAME"
43
+ - run: uv build
44
+ - uses: actions/upload-artifact@v7
45
+ with:
46
+ name: dist
47
+ path: dist/
48
+
49
+ publish:
50
+ name: Publish to PyPI
51
+ needs: build
52
+ if: startsWith(github.ref, 'refs/tags/v')
53
+ runs-on: ubuntu-latest
54
+ # PyPI's trusted publishing: no token is stored in the repository.
55
+ environment: pypi
56
+ permissions:
57
+ id-token: write
58
+ steps:
59
+ - uses: actions/download-artifact@v8
60
+ with:
61
+ name: dist
62
+ path: dist/
63
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,9 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ dist/
7
+ .env
8
+ .DS_Store
9
+ CLAUDE.local.md
osmund-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Osmund ApS
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.
osmund-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,42 @@
1
+ Metadata-Version: 2.5
2
+ Name: osmund
3
+ Version: 0.1.0
4
+ Summary: Async client for the Osmund API: electricity prices, consumption, cost and invoices
5
+ Project-URL: Documentation, https://osmundenergi.dk/docs/osmund-api/
6
+ Project-URL: Source, https://github.com/os-energy/python-osmund
7
+ Project-URL: Issues, https://github.com/os-energy/python-osmund/issues
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Framework :: AsyncIO
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Typing :: Typed
14
+ Requires-Python: >=3.14
15
+ Requires-Dist: aiohttp>=3.9
16
+ Description-Content-Type: text/markdown
17
+
18
+ # osmund
19
+
20
+ An async Python client for the [Osmund API](https://osmundenergi.dk/docs/osmund-api/): electricity prices, consumption, cost and invoices for Osmund's customers. It only reads.
21
+
22
+ ```python
23
+ import aiohttp
24
+ from datetime import date
25
+
26
+ from osmund import OsmundClient
27
+
28
+
29
+ async def main() -> None:
30
+ async with aiohttp.ClientSession() as session:
31
+ client = OsmundClient(session, "osm_...")
32
+ for location in await client.locations():
33
+ if location.api_access == "open":
34
+ prices = await client.prices(location.id, date.today(), "PT1H")
35
+ print(location.label, [i.total_inc_vat for i in prices.intervals])
36
+ ```
37
+
38
+ Create a personal key on [My page](https://osmundenergi.dk/min-side#api). The calls count toward your key's [limits](https://osmundenergi.dk/docs/osmund-api/#tag/limits).
39
+
40
+ The answers keep the API's field names, in snake_case. A value the API leaves out is `None`.
41
+
42
+ Each error the API documents has its own exception, all subclasses of `OsmundError`. A 429 or 503 raises `OsmundUnavailableError` with `retry_after` in seconds.
osmund-0.1.0/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # osmund
2
+
3
+ An async Python client for the [Osmund API](https://osmundenergi.dk/docs/osmund-api/): electricity prices, consumption, cost and invoices for Osmund's customers. It only reads.
4
+
5
+ ```python
6
+ import aiohttp
7
+ from datetime import date
8
+
9
+ from osmund import OsmundClient
10
+
11
+
12
+ async def main() -> None:
13
+ async with aiohttp.ClientSession() as session:
14
+ client = OsmundClient(session, "osm_...")
15
+ for location in await client.locations():
16
+ if location.api_access == "open":
17
+ prices = await client.prices(location.id, date.today(), "PT1H")
18
+ print(location.label, [i.total_inc_vat for i in prices.intervals])
19
+ ```
20
+
21
+ Create a personal key on [My page](https://osmundenergi.dk/min-side#api). The calls count toward your key's [limits](https://osmundenergi.dk/docs/osmund-api/#tag/limits).
22
+
23
+ The answers keep the API's field names, in snake_case. A value the API leaves out is `None`.
24
+
25
+ Each error the API documents has its own exception, all subclasses of `OsmundError`. A 429 or 503 raises `OsmundUnavailableError` with `retry_after` in seconds.
@@ -0,0 +1,47 @@
1
+ [project]
2
+ name = "osmund"
3
+ version = "0.1.0"
4
+ description = "Async client for the Osmund API: electricity prices, consumption, cost and invoices"
5
+ readme = "README.md"
6
+ requires-python = ">=3.14"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ dependencies = ["aiohttp>=3.9"]
10
+ classifiers = [
11
+ "Framework :: AsyncIO",
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3.14",
14
+ "Typing :: Typed",
15
+ ]
16
+
17
+ [project.urls]
18
+ Documentation = "https://osmundenergi.dk/docs/osmund-api/"
19
+ Source = "https://github.com/os-energy/python-osmund"
20
+ Issues = "https://github.com/os-energy/python-osmund/issues"
21
+
22
+ [build-system]
23
+ requires = ["hatchling"]
24
+ build-backend = "hatchling.build"
25
+
26
+ [dependency-groups]
27
+ dev = [
28
+ "pytest>=8",
29
+ "pytest-asyncio>=1",
30
+ "ruff>=0.14",
31
+ ]
32
+
33
+ [tool.pytest.ini_options]
34
+ asyncio_mode = "auto"
35
+ asyncio_default_fixture_loop_scope = "function"
36
+ testpaths = ["tests"]
37
+
38
+ [tool.ruff]
39
+ target-version = "py314"
40
+ line-length = 110
41
+
42
+ [tool.ruff.lint]
43
+ select = ["E", "F", "I", "UP", "B", "SIM", "RUF", "ASYNC", "PL", "DTZ", "T20"]
44
+ ignore = ["PLR2004", "PLR0913", "PLR0911"]
45
+
46
+ [tool.ruff.lint.per-file-ignores]
47
+ "scripts/*" = ["T20"]
@@ -0,0 +1,59 @@
1
+ """Write the test fixtures from the examples in the public Osmund API document.
2
+
3
+ Every fixture under tests/fixtures comes from the published OpenAPI document,
4
+ never from an account: this repository is public, and so is its history.
5
+
6
+ uv run python scripts/fixtures_from_openapi.py
7
+ """
8
+
9
+ import json
10
+ import sys
11
+ import urllib.request
12
+ from pathlib import Path
13
+
14
+ OPENAPI_URL = "https://osmundenergi.dk/docs/osmund-api/openapi.json"
15
+ FIXTURES = Path(__file__).resolve().parent.parent / "tests" / "fixtures"
16
+
17
+ # Route in the document -> fixture name for its 200 example.
18
+ ANSWERS = {
19
+ "/api/v1/me": "me",
20
+ "/api/v1/locations": "locations",
21
+ "/api/v1/locations/{id}/prices": "prices",
22
+ "/api/v1/locations/{id}/consumption": "consumption",
23
+ "/api/v1/locations/{id}/standby": "standby",
24
+ "/api/v1/locations/{id}/costs/rated": "costs_rated",
25
+ "/api/v1/invoices": "invoices",
26
+ "/api/v1/invoices/{invoiceNo}": "invoice",
27
+ }
28
+ # Every error status comes from the one route that documents all of them.
29
+ ERRORS_FROM = "/api/v1/locations/{id}/prices"
30
+
31
+
32
+ def example(response: dict) -> object:
33
+ """Return the `default` example of one documented response."""
34
+ return response["content"]["application/json"]["examples"]["default"]["value"]
35
+
36
+
37
+ def main() -> int:
38
+ """Read the document and write one JSON file per example."""
39
+ with urllib.request.urlopen(OPENAPI_URL, timeout=30) as answer:
40
+ document = json.load(answer)
41
+
42
+ FIXTURES.mkdir(parents=True, exist_ok=True)
43
+ written = {}
44
+ for route, name in ANSWERS.items():
45
+ written[name] = example(document["paths"][route]["get"]["responses"]["200"])
46
+ for status, response in document["paths"][ERRORS_FROM]["get"]["responses"].items():
47
+ if status != "200":
48
+ written[f"error_{status}"] = example(response)
49
+
50
+ for name, value in written.items():
51
+ path = FIXTURES / f"{name}.json"
52
+ path.write_text(json.dumps(value, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
53
+ print(f"wrote {path.relative_to(FIXTURES.parent.parent)}")
54
+ print(f"from {OPENAPI_URL}, version {document['info'].get('version')}")
55
+ return 0
56
+
57
+
58
+ if __name__ == "__main__":
59
+ sys.exit(main())
@@ -0,0 +1,65 @@
1
+ """An async client for the Osmund API: https://osmundenergi.dk/docs/osmund-api/."""
2
+
3
+ from .client import (
4
+ API_ACCESS_OPEN,
5
+ API_BASE,
6
+ KEY_PREFIX,
7
+ RESOLUTION_HOUR,
8
+ RESOLUTION_QUARTER_HOUR,
9
+ SCOPE_CONSUMPTION,
10
+ SCOPE_COSTS,
11
+ SCOPE_LABELS,
12
+ SCOPE_PRICES,
13
+ Amount,
14
+ ApiKey,
15
+ Invoice,
16
+ InvoiceLine,
17
+ Location,
18
+ OsmundAccessError,
19
+ OsmundApiError,
20
+ OsmundAuthError,
21
+ OsmundClient,
22
+ OsmundConnectionError,
23
+ OsmundError,
24
+ OsmundNotFoundError,
25
+ OsmundScopeError,
26
+ OsmundUnavailableError,
27
+ PriceDay,
28
+ PriceInterval,
29
+ RatedDay,
30
+ RatedMonth,
31
+ Reading,
32
+ StandbyMonth,
33
+ )
34
+
35
+ __all__ = [
36
+ "API_ACCESS_OPEN",
37
+ "API_BASE",
38
+ "KEY_PREFIX",
39
+ "RESOLUTION_HOUR",
40
+ "RESOLUTION_QUARTER_HOUR",
41
+ "SCOPE_CONSUMPTION",
42
+ "SCOPE_COSTS",
43
+ "SCOPE_LABELS",
44
+ "SCOPE_PRICES",
45
+ "Amount",
46
+ "ApiKey",
47
+ "Invoice",
48
+ "InvoiceLine",
49
+ "Location",
50
+ "OsmundAccessError",
51
+ "OsmundApiError",
52
+ "OsmundAuthError",
53
+ "OsmundClient",
54
+ "OsmundConnectionError",
55
+ "OsmundError",
56
+ "OsmundNotFoundError",
57
+ "OsmundScopeError",
58
+ "OsmundUnavailableError",
59
+ "PriceDay",
60
+ "PriceInterval",
61
+ "RatedDay",
62
+ "RatedMonth",
63
+ "Reading",
64
+ "StandbyMonth",
65
+ ]