Skip to main content

Basic Openweathermap API wrapper

Why

This is an extremely simple wrapper around the Openweathermap OneCall API. It currently only supports forecasts. As it is designed to be simple to use at the expense of features, the data is flattened from the nested structure to a single dictionary for each forecast. In the process some data points are dropped.

Users that are interested in the complete set of data points are encouraged to open an issue or submit a pull request.

Setup

  1. Obtain an Openweathermap API key at openweathermap.org
  2. Save the api key in a file '.api.txt' or the environment variable 'OPENWEATHERMAP_API_KEY'

Usage

from openweathermap import get_daily_forecast, APIError

try:
    forecast = get_daily_forecast(49.24966, -123.11934)  # Vancouver, BC, Canada
except APIError as e:
    # Deal with missing/incorrect API key or failed requests
    print(e)

Example return value for one day:

{
  "dt": "2021-10-29T13:00:00",
  "sunrise": "2021-10-29T08:56:00",
  "sunset": "2021-10-29T18:56:09",
  "clouds": 28,
  "snow": None,
  "rain": None,
  "pop": 0.26,
  "wind_speed": 5.32,
  "wind_deg": 283,
  "wind_gust": 7.76,
  "humidity": 72,
  "temp_day": 282.15,
  "temp_morn": 281.22,
  "temp_eve": 280.99
}

Metadata

Release files for openweathermap-simplified 0.0.1

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

Source distribution (sdist)

Source distribution for openweathermap-simplified 0.0.1
File Size Uploaded
openweathermap-simplified-0.0.1.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openweathermap-simplified 0.0.1
File Interpreter ABI Platform
openweathermap_simplified-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 32.2 kB

Release files / openweathermap-simplified-0.0.1.tar.gz

Download URL openweathermap-simplified-0.0.1.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6c3d2cbc715d193eacc701463f2325d20ff6b769db9d3f6e92aafce9cf783a9f
BLAKE2b-256 checksum
How to use checksums
62201d07de879f0305f1d50dd3ed8fe4056a3a3802f1dee0226137e6b083674a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.1

Release files / openweathermap_simplified-0.0.1-py3-none-any.whl

Download URL openweathermap_simplified-0.0.1-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
985e9c4c3f9aa0ae4532d7dcf60a3297c07a612c07e3f2998f648a43cb4adf8b
BLAKE2b-256 checksum
How to use checksums
197b3594afa7229f4db2135c9cd0ca2d2c70f0515bd6ea07da1e5a0d6653fc39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.1

Release history Release notifications | RSS feed

This release

0.0.1 This release

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