Skip to main content

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

Project description

python-weather pypi downloads Build Status license BLAZINGLY FAST!!!

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

Installation

$ pip install python-weather

Example

# 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.current.temperature)
    
    # get the weather forecast for a few days
    for forecast in weather.forecasts:
      print(forecast)
      
      # hourly forecasts
      for hourly in forecast.hourly:
        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())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-weather-1.0.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_weather-1.0.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file python-weather-1.0.0.tar.gz.

File metadata

  • Download URL: python-weather-1.0.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for python-weather-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3473c0001d2eb6303a057088380dbe8f95ad778391cbaa1aa8f5dc5b45cb7ecf
MD5 1de348f344302b440f935a8ce19e6f06
BLAKE2b-256 abdd74cf45372547b970af666a705e7f9d5233b851087a206d7c5fe38dd0fcb9

See more details on using hashes here.

File details

Details for the file python_weather-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: python_weather-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for python_weather-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 418d8c2745cb598f35bfc0f5c9e55aae55bf296ec01f8650740fe71f5ac4a27a
MD5 5ca031be754110e54d0de31077df24dc
BLAKE2b-256 ca443a50a6787c4e875ee94c8c0a40de7af3e3e5f11a6556c0712335351b308d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page