python-weather


Namepython-weather JSON
Version 2.0.2 PyPI version JSON
download
home_pageNone
SummaryA free and asynchronous weather API wrapper made in Python, for Python.
upload_time2024-04-25 16:47:46
maintainerNone
docs_urlNone
authornull8626
requires_python>=3.8
licenseMIT
keywords weather forecast weather-api weather-forecast
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # [python-weather][pypi-url] [![pypi][pypi-image]][pypi-url] [![downloads][downloads-image]][pypi-url] [![ko-fi][ko-fi-brief-image]][ko-fi-url]

[pypi-image]: https://img.shields.io/pypi/v/python-weather.svg?style=flat-square
[pypi-url]: https://pypi.org/project/python-weather/
[downloads-image]: https://img.shields.io/pypi/dm/python-weather?style=flat-square
[ko-fi-brief-image]: https://img.shields.io/badge/donations-ko--fi-red?color=ff5e5b&style=flat-square
[ko-fi-image]: https://ko-fi.com/img/githubbutton_sm.svg
[ko-fi-url]: https://ko-fi.com/null8626

A free and asynchronous weather Python API wrapper made in Python, for Python.

## Installation

```console
$ pip install python-weather
```

## Example

For more information, please read the [documentation](https://python-weather.readthedocs.io/en/latest/).

```py
# import the module
import python_weather

import asyncio
import os

async def getweather():
  # declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)
  async with python_weather.Client(unit=python_weather.IMPERIAL) as client:
    # fetch a weather forecast from a city
    weather = await client.get('New York')
    
    # returns the current day's forecast temperature (int)
    print(weather.temperature)
    
    # get the weather forecast for a few days
    for daily in weather.daily_forecasts:
      print(daily)
      
      # hourly forecasts
      for hourly in daily.hourly_forecasts:
        print(f' --> {hourly!r}')

if __name__ == '__main__':
  # see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop
  # for more details
  if os.name == 'nt':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
  
  asyncio.run(getweather())
```

## Donations

If you want to support this project, consider donating! ❤

[![ko-fi][ko-fi-image]][ko-fi-url]

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "python-weather",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "weather, forecast, weather-api, weather-forecast",
    "author": "null8626",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d3/a0/0b57abcce6b24f0c74723a1366b9371880f86a119f9a39314c4e18a8ad44/python_weather-2.0.2.tar.gz",
    "platform": null,
    "description": "# [python-weather][pypi-url] [![pypi][pypi-image]][pypi-url] [![downloads][downloads-image]][pypi-url] [![ko-fi][ko-fi-brief-image]][ko-fi-url]\r\n\r\n[pypi-image]: https://img.shields.io/pypi/v/python-weather.svg?style=flat-square\r\n[pypi-url]: https://pypi.org/project/python-weather/\r\n[downloads-image]: https://img.shields.io/pypi/dm/python-weather?style=flat-square\r\n[ko-fi-brief-image]: https://img.shields.io/badge/donations-ko--fi-red?color=ff5e5b&style=flat-square\r\n[ko-fi-image]: https://ko-fi.com/img/githubbutton_sm.svg\r\n[ko-fi-url]: https://ko-fi.com/null8626\r\n\r\nA free and asynchronous weather Python API wrapper made in Python, for Python.\r\n\r\n## Installation\r\n\r\n```console\r\n$ pip install python-weather\r\n```\r\n\r\n## Example\r\n\r\nFor more information, please read the [documentation](https://python-weather.readthedocs.io/en/latest/).\r\n\r\n```py\r\n# import the module\r\nimport python_weather\r\n\r\nimport asyncio\r\nimport os\r\n\r\nasync def getweather():\r\n  # declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)\r\n  async with python_weather.Client(unit=python_weather.IMPERIAL) as client:\r\n    # fetch a weather forecast from a city\r\n    weather = await client.get('New York')\r\n    \r\n    # returns the current day's forecast temperature (int)\r\n    print(weather.temperature)\r\n    \r\n    # get the weather forecast for a few days\r\n    for daily in weather.daily_forecasts:\r\n      print(daily)\r\n      \r\n      # hourly forecasts\r\n      for hourly in daily.hourly_forecasts:\r\n        print(f' --> {hourly!r}')\r\n\r\nif __name__ == '__main__':\r\n  # see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop\r\n  # for more details\r\n  if os.name == 'nt':\r\n    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\r\n  \r\n  asyncio.run(getweather())\r\n```\r\n\r\n## Donations\r\n\r\nIf you want to support this project, consider donating! \u2764\r\n\r\n[![ko-fi][ko-fi-image]][ko-fi-url]\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A free and asynchronous weather API wrapper made in Python, for Python.",
    "version": "2.0.2",
    "project_urls": {
        "Changelog": "https://python-weather.readthedocs.io/en/latest/changelog.html",
        "Documentation": "https://python-weather.readthedocs.io/en/latest/",
        "Donations": "https://ko-fi.com/null8626",
        "Homepage": "https://python-weather.readthedocs.io/en/latest/",
        "Repository": "https://github.com/null8626/python-weather"
    },
    "split_keywords": [
        "weather",
        " forecast",
        " weather-api",
        " weather-forecast"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8b3990d02457740bfc05142a7dc59bad104aa601a471d5cf4a94fb5cb5e6f242",
                "md5": "e12d0674dc0856641c6045bedc27e43d",
                "sha256": "e1e26d93ce4bc1a97e6d0b0ec59a1c1ef6d829a493cfaf7f45edb35797363d86"
            },
            "downloads": -1,
            "filename": "python_weather-2.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e12d0674dc0856641c6045bedc27e43d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 12217,
            "upload_time": "2024-04-25T16:47:45",
            "upload_time_iso_8601": "2024-04-25T16:47:45.030692Z",
            "url": "https://files.pythonhosted.org/packages/8b/39/90d02457740bfc05142a7dc59bad104aa601a471d5cf4a94fb5cb5e6f242/python_weather-2.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d3a00b57abcce6b24f0c74723a1366b9371880f86a119f9a39314c4e18a8ad44",
                "md5": "621fa69caf60a7959ca0613c2748a1df",
                "sha256": "904e72885a3dd6494870540df3c06cb7cecef363d4740d6343853dc2d14db9d3"
            },
            "downloads": -1,
            "filename": "python_weather-2.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "621fa69caf60a7959ca0613c2748a1df",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 11798,
            "upload_time": "2024-04-25T16:47:46",
            "upload_time_iso_8601": "2024-04-25T16:47:46.812531Z",
            "url": "https://files.pythonhosted.org/packages/d3/a0/0b57abcce6b24f0c74723a1366b9371880f86a119f9a39314c4e18a8ad44/python_weather-2.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-25 16:47:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "null8626",
    "github_project": "python-weather",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "python-weather"
}
        
Elapsed time: 0.26587s