{"id":15698444,"url":"https://github.com/bachya/pyopenuv","last_synced_at":"2025-04-06T16:14:42.123Z","repository":{"id":32797887,"uuid":"142930174","full_name":"bachya/pyopenuv","owner":"bachya","description":"☀️A simple Python API to retrieve data from openuv.io","archived":false,"fork":false,"pushed_at":"2025-03-27T08:13:47.000Z","size":1609,"stargazers_count":6,"open_issues_count":5,"forks_count":6,"subscribers_count":2,"default_branch":"dev","last_synced_at":"2025-03-30T15:09:27.667Z","etag":null,"topics":["asyncio","health","python3","sun","ultraviolet"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bachya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-30T21:29:47.000Z","updated_at":"2024-11-12T18:01:29.000Z","dependencies_parsed_at":"2023-12-08T18:27:09.065Z","dependency_job_id":"483f81c9-4c18-4280-be8d-e55caa663c88","html_url":"https://github.com/bachya/pyopenuv","commit_stats":{"total_commits":620,"total_committers":8,"mean_commits":77.5,"dds":0.3096774193548387,"last_synced_commit":"198d1daebd466b06f1eda042e5fa22761d24ac35"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bachya%2Fpyopenuv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bachya%2Fpyopenuv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bachya%2Fpyopenuv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bachya%2Fpyopenuv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bachya","download_url":"https://codeload.github.com/bachya/pyopenuv/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509237,"owners_count":20950232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncio","health","python3","sun","ultraviolet"],"created_at":"2024-10-03T19:27:51.914Z","updated_at":"2025-04-06T16:14:42.100Z","avatar_url":"https://github.com/bachya.png","language":"Python","funding_links":["https://www.buymeacoffee.com/bachya1208P"],"categories":[],"sub_categories":[],"readme":"# ☀️ pyopenuv: A simple Python API for data from openuv.io\n\n[![CI][ci-badge]][ci]\n[![PyPI][pypi-badge]][pypi]\n[![Version][version-badge]][version]\n[![License][license-badge]][license]\n[![Code Coverage][codecov-badge]][codecov]\n[![Maintainability][maintainability-badge]][maintainability]\n\n\u003ca href=\"https://www.buymeacoffee.com/bachya1208P\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" height=\"41\" width=\"174\"\u003e\u003c/a\u003e\n\n`pyopenuv` is a simple Python library for retrieving UV-related information from\n[openuv.io][openuv].\n\n- [Installation](#installation)\n- [Python Versions](#python-versions)\n- [API Key](#api-key)\n- [Usage](#usage)\n- [Contributing](#contributing)\n\n# Installation\n\n```bash\npip install pyopenuv\n```\n\n# Python Versions\n\n`pyopenuv` is currently supported on:\n\n- Python 3.10\n- Python 3.11\n- Python 3.12\n\n# API Key\n\nYou can get an API key from [the OpenUV console][openuv-console].\n\n# Usage\n\n```python\nimport asyncio\n\nfrom pyopenuv import Client\nfrom pyopenuv.errors import OpenUvError\n\n\nasync def main():\n    client = Client(\n        \"\u003cOPENUV_API_KEY\u003e\", \"\u003cLATITUDE\u003e\", \"\u003cLONGITUDE\u003e\", altitude=\"\u003cALTITUDE\u003e\"\n    )\n\n    try:\n        # Get the current status of the OpenUV API:\n        print(await client.api_status())\n        # \u003e\u003e\u003e True\n\n        # Get current UV info:\n        print(await client.uv_index())\n        # \u003e\u003e\u003e { \"result\": { ... } }\n\n        # Get forecasted UV info:\n        print(await client.uv_forecast())\n        # \u003e\u003e\u003e { \"result\": { ... } }\n\n        # Get UV protection window:\n        print(await client.uv_protection_window())\n        # \u003e\u003e\u003e { \"result\": { ... } }\n\n        # Get API usage info/statistics:\n        print(await client.api_statistics())\n        # \u003e\u003e\u003e { \"result\": { ... } }\n    except OpenUvError as err:\n        print(f\"There was an error: {err}\")\n\n\nasyncio.run(main())\n```\n\n## Checking API Status Before Requests\n\nIf you would prefer to not call `api_status` manually, you can configure the `Client` object\nto automatically check the status of the OpenUV API before executing any of the API\nmethods—simply pass the `check_status_before_request` parameter:\n\n```python\nimport asyncio\n\nfrom pyopenuv import Client\nfrom pyopenuv.errors import ApiUnavailableError, OpenUvError\n\n\nasync def main():\n    client = Client(\n        \"\u003cOPENUV_API_KEY\u003e\",\n        \"\u003cLATITUDE\u003e\",\n        \"\u003cLONGITUDE\u003e\",\n        altitude=\"\u003cALTITUDE\u003e\",\n        check_status_before_request=True,\n    )\n\n    try:\n        print(await client.uv_index())\n    except ApiUnavailableError:\n        print(\"The API is unavailable\")\n    except OpenUvError as err:\n        print(f\"There was an error: {err}\")\n\n\nasyncio.run(main())\n```\n\n## Connection Pooling\n\nBy default, the library creates a new connection to OpenUV with each coroutine. If you\nare calling a large number of coroutines (or merely want to squeeze out every second of\nruntime savings possible), an [`aiohttp`][aiohttp] `ClientSession` can be used for\nconnection pooling:\n\n```python\nimport asyncio\n\nfrom aiohttp import ClientSession\nfrom pyopenuv import Client\nfrom pyopenuv.errors import OpenUvError\n\n\nasync def main():\n    async with ClientSession() as session:\n        client = Client(\n            \"\u003cOPENUV_API_KEY\u003e\",\n            \"\u003cLATITUDE\u003e\",\n            \"\u003cLONGITUDE\u003e\",\n            altitude=\"\u003cALTITUDE\u003e\",\n            session=session,\n        )\n\n        try:\n            print(await client.uv_index())\n        except OpenUvError as err:\n            print(f\"There was an error: {err}\")\n\n\nasyncio.run(main())\n```\n\n# Contributing\n\nThanks to all of [our contributors][contributors] so far!\n\n1. [Check for open features/bugs][issues] or [initiate a discussion on one][new-issue].\n2. [Fork the repository][fork].\n3. (_optional, but highly recommended_) Create a virtual environment: `python3 -m venv .venv`\n4. (_optional, but highly recommended_) Enter the virtual environment: `source ./.venv/bin/activate`\n5. Install the dev environment: `script/setup`\n6. Code your new feature or bug fix on a new branch.\n7. Write tests that cover your new functionality.\n8. Run tests and ensure 100% code coverage: `poetry run pytest --cov pyopenuv tests`\n9. Update `README.md` with any new documentation.\n10. Submit a pull request!\n\n[aiohttp]: https://github.com/aio-libs/aiohttp\n[ci-badge]: https://img.shields.io/github/actions/workflow/status/bachya/pyopenuv/test.yml\n[ci]: https://github.com/bachya/pyopenuv/actions\n[codecov-badge]: https://codecov.io/gh/bachya/pyopenuv/branch/dev/graph/badge.svg\n[codecov]: https://codecov.io/gh/bachya/pyopenuv\n[contributors]: https://github.com/bachya/pyopenuv/graphs/contributors\n[fork]: https://github.com/bachya/pyopenuv/fork\n[issues]: https://github.com/bachya/pyopenuv/issues\n[license-badge]: https://img.shields.io/pypi/l/pyopenuv.svg\n[license]: https://github.com/bachya/pyopenuv/blob/main/LICENSE\n[maintainability-badge]: https://api.codeclimate.com/v1/badges/a03c9e96f19a3dc37f98/maintainability\n[maintainability]: https://codeclimate.com/github/bachya/pyopenuv/maintainability\n[new-issue]: https://github.com/bachya/pyopenuv/issues/new\n[new-issue]: https://github.com/bachya/pyopenuv/issues/new\n[openuv]: https://openuv.io/\n[openuv-console]: https://www.openuv.io/console\n[pypi-badge]: https://img.shields.io/pypi/v/pyopenuv.svg\n[pypi]: https://pypi.python.org/pypi/pyopenuv\n[version-badge]: https://img.shields.io/pypi/pyversions/pyopenuv.svg\n[version]: https://pypi.python.org/pypi/pyopenuv\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbachya%2Fpyopenuv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbachya%2Fpyopenuv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbachya%2Fpyopenuv/lists"}