# YaWeather | Yandex Weather API
[![Python](https://img.shields.io/badge/Python-3.6%20%7C%203.7%20%7C%203.8-blue.svg?longCache=true)]()
[![PyPI](https://img.shields.io/pypi/v/yaweather.svg)](https://pypi.python.org/pypi/yaweather)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/uburuntu/yaweather/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/uburuntu/yaweather.svg?branch=master)](https://travis-ci.org/uburuntu/yaweather)
☀️🌤🌧🌩❄️ Yandex Weather API wrapper with typings and asyncio support.
Docs: https://tech.yandex.com/weather/doc/dg/concepts/forecast-test-docpage ([RU](https://yandex.ru/dev/weather/doc/dg/concepts/forecast-test-docpage/))
Get API Key: https://developer.tech.yandex.ru/services/18
⚠️ **Warning**: As a developer of this library, I recommend you not to use Yandex Weather API, here are some reasons:
- Incomplete responses even for metropolises — you can [have a look](yaweather/models/forecast.py) to all `Optional` fields that I had to use in models, that means you should add `None` checks before access literally to any attribute
- Bad official documentation — for example, I [really had to](scripts/build_models.py) parse html code of doc pages just because tables copying was broken
- Incomprehensible and big delay answers from support team
- Few requests available — 50 per day on free rate and 5000 per day for one test month
- Closed information about real prices that are accessible only via support team
Consider usage of [OpenWeatherMap](https://openweathermap.org/api) with 1 mln free requests every month and really [good documentation](https://openweathermap.org/api/one-call-api) which easy to understand and parse.
![](https://i.imgur.com/pMf2tpT.png)
## 📝 Table of Contents
- [🎒 Installation](#-installation)
- [🛠 Examples](#-examples)
- [Simple](#simple)
- [Simple Async](#simple-async)
- [Forecasts](#forecasts)
- [Forecasts Async](#forecasts-async)
- [📜 Manual](#-manual)
- [Methods](#methods)
- [Types](#types)
- [In case of unsupported types](#in-case-of-unsupported-types)
- [👨🏻💻 Author](#-author)
- [💬 Contributing](#-contributing)
- [📝 License](#-license)
---
## 🎒 Installation
Just
```
pip install yaweather
```
## 🛠 Examples
### Simple
```python3
from yaweather import UnitedKingdom, YaWeather
y = YaWeather(api_key='secret')
res = y.forecast(UnitedKingdom.London)
print(f'Now: {res.fact.temp} °C, feels like {res.fact.feels_like} °C')
print(f'Condition: {res.fact.condition}')
```
Output:
```text
Now: 18.0 °C, feels like 15.0 °C
Condition: cloudy
```
### Simple Async
```python3
import asyncio
from yaweather import Russia, YaWeatherAsync
async def main():
async with YaWeatherAsync(api_key='secret') as y:
res = await y.forecast(Russia.Moscow)
print(f'Now: {res.fact.temp} °C, feels like {res.fact.feels_like} °C')
print(f'Condition: {res.fact.condition}')
asyncio.run(main())
```
Output:
```text
Now: 16.0 °C, feels like 16.0 °C
Condition: clear
```
### Forecasts
```python3
from yaweather import UnitedStates, YaWeather
y = YaWeather(api_key='secret')
res = y.forecast(UnitedStates.NewYork)
for f in res.forecasts:
day = f.parts.day_short
print(f'{f.date} | {day.temp} °C, {day.condition}')
```
Output:
```text
2020-07-30 | 32.0 °C, cloudy
2020-07-31 | 26.0 °C, light-rain
2020-08-01 | 28.0 °C, cloudy
2020-08-02 | 28.0 °C, rain
2020-08-03 | 28.0 °C, light-rain
2020-08-04 | 27.0 °C, rain
2020-08-05 | 29.0 °C, light-rain
```
### Forecasts Async
```python3
import asyncio
from yaweather import China, YaWeatherAsync
async def main():
async with YaWeatherAsync(api_key='secret') as y:
res = await y.forecast(China.Beijing)
for f in res.forecasts:
day = f.parts.day_short
print(f'{f.date} | {day.temp} °C, {day.condition}')
asyncio.run(main())
```
Output:
```text
2020-07-31 | 34.0 °C, light-rain
2020-08-01 | 34.0 °C, cloudy
2020-08-02 | 30.0 °C, heavy-rain
2020-08-03 | 33.0 °C, cloudy
2020-08-04 | 35.0 °C, cloudy
2020-08-05 | 34.0 °C, light-rain
2020-08-06 | 31.0 °C, heavy-rain
```
## 📜 Manual
### Methods
API have one method:
* `forecast` — request for the forecast, return type: `ResponseForecast`
### Types
This library uses [pydantic](https://github.com/samuelcolvin/pydantic/) for parsing API responses.
You can see data models in [yaweather/models](yaweather/models).
### In case of unsupported types
API results can change and the library may not parse the new result. So you can request «raw» dicts:
```python3
raw_dict = y.forecast_raw(UnitedKingdom.London)
```
## 👨🏻💻 Author
**Ramzan Bekbulatov**:
- Telegram: [@rm_bk](https://t.me/rm_bk)
- Github: [@uburuntu](https://github.com/uburuntu)
## 💬 Contributing
Contributions, issues and feature requests are welcome!
## 📝 License
This project is [MIT](https://github.com/uburuntu/yaweather/blob/master/LICENSE) licensed.
Raw data
{
"_id": null,
"home_page": null,
"name": "yaweather",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "yandex, ya, weather, api",
"author": null,
"author_email": "uburuntu <github@rmbk.me>",
"download_url": "https://files.pythonhosted.org/packages/96/e7/1fd2bc814145e686c62e6e1caa6ce1389ab7bae972f619ca10f4117ebdb8/yaweather-1.3.0.tar.gz",
"platform": "all",
"description": "# YaWeather | Yandex Weather API\n\n[![Python](https://img.shields.io/badge/Python-3.6%20%7C%203.7%20%7C%203.8-blue.svg?longCache=true)]()\n[![PyPI](https://img.shields.io/pypi/v/yaweather.svg)](https://pypi.python.org/pypi/yaweather)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/uburuntu/yaweather/blob/master/LICENSE)\n\n[![Build Status](https://travis-ci.org/uburuntu/yaweather.svg?branch=master)](https://travis-ci.org/uburuntu/yaweather)\n\n\u2600\ufe0f\ud83c\udf24\ud83c\udf27\ud83c\udf29\u2744\ufe0f Yandex Weather API wrapper with typings and asyncio support.\n\nDocs: https://tech.yandex.com/weather/doc/dg/concepts/forecast-test-docpage ([RU](https://yandex.ru/dev/weather/doc/dg/concepts/forecast-test-docpage/))\n\nGet API Key: https://developer.tech.yandex.ru/services/18\n\n\u26a0\ufe0f **Warning**: As a developer of this library, I recommend you not to use Yandex Weather API, here are some reasons:\n- Incomplete responses even for metropolises \u2014 you can [have a look](yaweather/models/forecast.py) to all `Optional` fields that I had to use in models, that means you should add `None` checks before access literally to any attribute \n- Bad official documentation \u2014 for example, I [really had to](scripts/build_models.py) parse html code of doc pages just because tables copying was broken\n- Incomprehensible and big delay answers from support team\n- Few requests available \u2014 50 per day on free rate and 5000 per day for one test month\n- Closed information about real prices that are accessible only via support team\n\nConsider usage of [OpenWeatherMap](https://openweathermap.org/api) with 1 mln free requests every month and really [good documentation](https://openweathermap.org/api/one-call-api) which easy to understand and parse.\n\n![](https://i.imgur.com/pMf2tpT.png)\n\n## \ud83d\udcdd Table of Contents\n\n- [\ud83c\udf92 Installation](#-installation)\n- [\ud83d\udee0 Examples](#-examples)\n - [Simple](#simple)\n - [Simple Async](#simple-async)\n - [Forecasts](#forecasts)\n - [Forecasts Async](#forecasts-async)\n- [\ud83d\udcdc Manual](#-manual)\n - [Methods](#methods)\n - [Types](#types)\n - [In case of unsupported types](#in-case-of-unsupported-types)\n- [\ud83d\udc68\ud83c\udffb\u200d\ud83d\udcbb Author](#-author)\n- [\ud83d\udcac Contributing](#-contributing)\n- [\ud83d\udcdd License](#-license)\n\n\n---\n\n## \ud83c\udf92 Installation\nJust\n```\npip install yaweather\n```\n\n## \ud83d\udee0 Examples\n\n### Simple\n\n```python3\nfrom yaweather import UnitedKingdom, YaWeather\n\ny = YaWeather(api_key='secret')\nres = y.forecast(UnitedKingdom.London)\n\nprint(f'Now: {res.fact.temp} \u00b0C, feels like {res.fact.feels_like} \u00b0C')\nprint(f'Condition: {res.fact.condition}')\n\n```\nOutput:\n```text\nNow: 18.0 \u00b0C, feels like 15.0 \u00b0C\nCondition: cloudy\n```\n\n### Simple Async\n\n```python3\nimport asyncio\n\nfrom yaweather import Russia, YaWeatherAsync\n\n\nasync def main():\n async with YaWeatherAsync(api_key='secret') as y:\n res = await y.forecast(Russia.Moscow)\n\n print(f'Now: {res.fact.temp} \u00b0C, feels like {res.fact.feels_like} \u00b0C')\n print(f'Condition: {res.fact.condition}')\n\n\nasyncio.run(main())\n\n```\nOutput:\n```text\nNow: 16.0 \u00b0C, feels like 16.0 \u00b0C\nCondition: clear\n```\n\n### Forecasts\n\n```python3\nfrom yaweather import UnitedStates, YaWeather\n\ny = YaWeather(api_key='secret')\n\nres = y.forecast(UnitedStates.NewYork)\n\nfor f in res.forecasts:\n day = f.parts.day_short\n print(f'{f.date} | {day.temp} \u00b0C, {day.condition}')\n\n```\nOutput:\n```text\n2020-07-30 | 32.0 \u00b0C, cloudy\n2020-07-31 | 26.0 \u00b0C, light-rain\n2020-08-01 | 28.0 \u00b0C, cloudy\n2020-08-02 | 28.0 \u00b0C, rain\n2020-08-03 | 28.0 \u00b0C, light-rain\n2020-08-04 | 27.0 \u00b0C, rain\n2020-08-05 | 29.0 \u00b0C, light-rain\n```\n\n### Forecasts Async\n\n```python3\nimport asyncio\n\nfrom yaweather import China, YaWeatherAsync\n\n\nasync def main():\n async with YaWeatherAsync(api_key='secret') as y:\n res = await y.forecast(China.Beijing)\n\n for f in res.forecasts:\n day = f.parts.day_short\n print(f'{f.date} | {day.temp} \u00b0C, {day.condition}')\n\n\nasyncio.run(main())\n\n```\nOutput:\n```text\n2020-07-31 | 34.0 \u00b0C, light-rain\n2020-08-01 | 34.0 \u00b0C, cloudy\n2020-08-02 | 30.0 \u00b0C, heavy-rain\n2020-08-03 | 33.0 \u00b0C, cloudy\n2020-08-04 | 35.0 \u00b0C, cloudy\n2020-08-05 | 34.0 \u00b0C, light-rain\n2020-08-06 | 31.0 \u00b0C, heavy-rain\n```\n\n## \ud83d\udcdc Manual\n\n### Methods\nAPI have one method:\n* `forecast` \u2014 request for the forecast, return type: `ResponseForecast`\n\n### Types\nThis library uses [pydantic](https://github.com/samuelcolvin/pydantic/) for parsing API responses.\nYou can see data models in [yaweather/models](yaweather/models).\n\n### In case of unsupported types\nAPI results can change and the library may not parse the new result. So you can request \u00abraw\u00bb dicts: \n```python3\nraw_dict = y.forecast_raw(UnitedKingdom.London)\n```\n\n## \ud83d\udc68\ud83c\udffb\u200d\ud83d\udcbb Author\n\n**Ramzan Bekbulatov**:\n- Telegram: [@rm_bk](https://t.me/rm_bk)\n- Github: [@uburuntu](https://github.com/uburuntu)\n\n## \ud83d\udcac Contributing\n\nContributions, issues and feature requests are welcome! \n\n## \ud83d\udcdd License\n\nThis project is [MIT](https://github.com/uburuntu/yaweather/blob/master/LICENSE) licensed.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Yandex Weather API with asyncio support and typings",
"version": "1.3.0",
"project_urls": {
"Download": "https://github.com/uburuntu/yaweather/archive/master.zip",
"Homepage": "https://github.com/uburuntu/yaweather"
},
"split_keywords": [
"yandex",
" ya",
" weather",
" api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "58b3192e80e4182990acdd7978770a78d7ee6bf3ff252a5038c60c5c82a8594c",
"md5": "6e0dc4e0ffd6f019901f395100dfdf5c",
"sha256": "580be01f9525e7e433e212e5edd4b781ebf34e95f96f9b9d22b29091b492731d"
},
"downloads": -1,
"filename": "yaweather-1.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6e0dc4e0ffd6f019901f395100dfdf5c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 29408,
"upload_time": "2024-11-23T20:19:11",
"upload_time_iso_8601": "2024-11-23T20:19:11.379637Z",
"url": "https://files.pythonhosted.org/packages/58/b3/192e80e4182990acdd7978770a78d7ee6bf3ff252a5038c60c5c82a8594c/yaweather-1.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "96e71fd2bc814145e686c62e6e1caa6ce1389ab7bae972f619ca10f4117ebdb8",
"md5": "5a3bf88a9e6275af9610472bfe9173db",
"sha256": "0ebf2e463deb7c5706156a68dee40aaa2605a34eaf278c8ee876c14fd6efc73c"
},
"downloads": -1,
"filename": "yaweather-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "5a3bf88a9e6275af9610472bfe9173db",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 30094,
"upload_time": "2024-11-23T20:19:12",
"upload_time_iso_8601": "2024-11-23T20:19:12.744563Z",
"url": "https://files.pythonhosted.org/packages/96/e7/1fd2bc814145e686c62e6e1caa6ce1389ab7bae972f619ca10f4117ebdb8/yaweather-1.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-23 20:19:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "uburuntu",
"github_project": "yaweather",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "aiohttp",
"specs": [
[
">=",
"3.6"
]
]
},
{
"name": "pydantic",
"specs": [
[
">=",
"2.5"
]
]
},
{
"name": "requests",
"specs": [
[
">=",
"2.24"
]
]
}
],
"lcname": "yaweather"
}