Skip to main content

Command Palette

Search for a command to run...

WeatherKit

Library to get weather details in the most easy way possible

Updated
•2 min read•View as Markdown
WeatherKit

Presenting yet another open-source weather library, WeatherKit is a simple and powerful for Python. It allows you to get the weather for any location in the world in a simple and easy-to-use way without any API keys.

It has to nothing with apple weatherkit. It is just a name. (Well every meaningful name is already taken on pypi)

Motivation

I was working on a project named H2O that required weather data. I was looking for a simple library that could provide me with the weather data I needed. I found a few libraries, but none of them were simple and easy to use. So I decided to create my own weather library that would be simple and easy to use. And that's how WeatherKit was born.

Getting Started

WeatherKit is hosted on GitHub and can be installed using pip.

pip install WeatherKit

Installing from Source

git clone https://github.com/suvanbanerjee/WeatherKit.git
cd WeatherKit
python setup.py sdist bdist_wheel
pip install dist/*

Usage

WeatherKit don't require any API key. and can fetch weather data from address or lat, long.

import weatherkit
NYC = weatherkit.current_weather('New York')
print(NYC.temperature())
# Output: 20.0
print(NYC.temperature(units='imperial'))
# Output: 68.0
print(NYC.humidity())
# Output: 50
print(NYC.weather_code())
# Output: 3
print(NYC.precipitation())
# Output: 0.0

Using Geo-Coordinates

import weatherkit
NYC = weatherkit.current_weather(40.7128, -74.0060)
print(NYC.temperature())
# Output: 20.0
print(NYC.temperature(units='imperial'))
# Output: 68.0
print(NYC.humidity())
# Output: 50
print(NYC.weather_code())
# Output: 3
print(NYC.precipitation())
# Output: 0.0

Forecast is also available

import weatherkit
NYC = weatherkit.daily_forecast('New York')

print(NYC.max_temperature())
# Output: 20.0
print(NYC.max_temperature(units='imperial'))
# Output: 68.0
print(NYC.min_temperature())
# Output: 10.0
print(NYC.max_temperature(day_offset=3))
# Output: 20.0
print(NYC.max_temperature(day_offset=3, units='imperial'))
# Output: 68.0
print(NYC.precipitation_sum())
# Output: 0.0
print(NYC.precipitation_sum(day_offset=3))
# Output: 3.2
print(NYC.precipitation_sum(units='imperial'))
# Output: 0.0 (in Inches)
print(NYC.weather_code())
# Output: 3
print(NYC.weather_code(day_offset=3))
# Output: 3

It's use cases

  • Scraping weather data for analysis

  • Some cool automation projects

  • Weather backend for your apps

  • Use with your IOT projects

    The limitation is your imagination

WeatherKit thrives on your feedback

WeatherKit needs users and a community to be complete. So please, give it a try, like it, tell me what you think, or let me know if something's wrong. I'm excited to see where we can go with it together! So please, give it a shot, star it, criticize it, open an issue...