Package: yaweather
YaWeather | Yandex Weather API☀️🌤🌧🌩❄️ 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 canhave a lookto allOptionalfields that I had to use in models, that means you should addNonechecks before access literally to any attributeBad official documentation — for example, Ireally had toparse html code of doc pages just because tables copying was brokenIncomprehensible and big delay answers from support teamFew requests available — 50 per day on free rate and 5000 per day for one test monthClosed information about real prices that are accessible only via support teamConsider usage ofOpenWeatherMapwith 1 mln free requests every month and reallygood documentationwhich easy to understand and parse.📝 Table of Contents🎒 Installation🛠 ExamplesSimpleSimple AsyncForecastsForecasts Async📜 ManualMethodsTypesIn case of unsupported types👨🏻‍💻 Author💬 Contributing📝 License🎒 InstallationJustpip install yaweather🛠 ExamplesSimplefromyaweatherimportUnitedKingdom,YaWeathery=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: cloudySimple AsyncimportasynciofromyaweatherimportRussia,YaWeatherAsyncasyncdefmain():asyncwithYaWeatherAsync(api_key='secret')asy:res=awaity.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: clearForecastsfromyaweatherimportUnitedStates,YaWeathery=YaWeather(api_key='secret')res=y.forecast(UnitedStates.NewYork)forfinres.forecasts:day=f.parts.day_shortprint(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-rainForecasts AsyncimportasynciofromyaweatherimportChina,YaWeatherAsyncasyncdefmain():asyncwithYaWeatherAsync(api_key='secret')asy:res=awaity.forecast(China.Beijing)forfinres.forecasts:day=f.parts.day_shortprint(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📜 ManualMethodsAPI have one method:forecast— request for the forecast, return type:ResponseForecastTypesThis library usespydanticfor parsing API responses.
You can see data models inyaweather/models.In case of unsupported typesAPI 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)👨🏻‍💻 AuthorRamzan Bekbulatov:Telegram:@rm_bkGithub:@uburuntu💬 ContributingContributions, issues and feature requests are welcome!📝 LicenseThis project isMITlicensed.