Skip to main content

YaWeather | Yandex Weather API

Python PyPI License: MIT

Build Status

☀️🌤🌧🌩❄️ Yandex Weather API wrapper with typings and asyncio support.

Docs: https://tech.yandex.com/weather/doc/dg/concepts/forecast-test-docpage (RU)

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 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 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 with 1 mln free requests every month and really good documentation which easy to understand and parse.

📝 Table of Contents


🎒 Installation

Just

pip install yaweather

🛠 Examples

Simple

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:

Now: 18.0 °C, feels like 15.0 °C
Condition: cloudy

Simple Async

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:

Now: 16.0 °C, feels like 16.0 °C
Condition: clear

Forecasts

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:

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

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:

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 for parsing API responses. You can see data models in 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:

raw_dict = y.forecast_raw(UnitedKingdom.London)

👨🏻‍💻 Author

Ramzan Bekbulatov:

💬 Contributing

Contributions, issues and feature requests are welcome!

📝 License

This project is MIT licensed.

Metadata

Release files for yaweather 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yaweather 1.3.0
File Size Uploaded
yaweather-1.3.0.tar.gz 30.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yaweather 1.3.0
File Interpreter ABI Platform
yaweather-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 59.5 kB

Release files / yaweather-1.3.0.tar.gz

Download URL yaweather-1.3.0.tar.gz
Size 30.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0ebf2e463deb7c5706156a68dee40aaa2605a34eaf278c8ee876c14fd6efc73c
BLAKE2b-256 checksum
How to use checksums
96e71fd2bc814145e686c62e6e1caa6ce1389ab7bae972f619ca10f4117ebdb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2024.

Transparency log

Release files / yaweather-1.3.0-py3-none-any.whl

Download URL yaweather-1.3.0-py3-none-any.whl
Size 29.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
580be01f9525e7e433e212e5edd4b781ebf34e95f96f9b9d22b29091b492731d
BLAKE2b-256 checksum
How to use checksums
58b3192e80e4182990acdd7978770a78d7ee6bf3ff252a5038c60c5c82a8594c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.7

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page