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.1.0.tar.gz (12.4 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.1.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for python-weather-1.1.0.tar.gz
Algorithm Hash digest
SHA256 25011f8dba6bdf5cb7b48986ecf212c955932802c4aebc9c1bc9e4e515ce5908
MD5 950f9cddc00222dbe517676e52b17c6b
BLAKE2b-256 c3196ffacc9d143a3141ddb67034955d80d1a8b35bd100f48a23967c2df44a47

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for python_weather-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7710b644996981c8491350b6a4a954cae9e2d4109376ef9a4d5f3a6c42bf7aa2
MD5 111e78e76f980f22635e0f857f4e5bbd
BLAKE2b-256 e36c4ace20878f4fcddf5885a176e97aca0607b0f7ddfdebe667e5f72e5cf4f8

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