bttrwttrin

wttr.in API, but better.

Pure Nim score 15/100 · last commit 2024-02-06 · 3 stars · tests present · no docs generated

Summary

Latest Version 1.0.0
License GPL-3.0-or-later
CI Status Failing
Stars 3
Forks 0
Open Issues 0
Last Commit 2024-02-06
Downloads 0
Last Indexed 2026-07-21 05:26

Authors

  • nirokay

Installation

nimble install bttrwttrin
choosenim install bttrwttrin
git clone https://github.com/nirokay/bttrwttrin

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
bttrwttrin - - - - - - -

Dependencies

Package Version Optional
nim >= 2.0.0 No

README

bttrwttrin

Better wttr.in is a library, that lets you easily request weather for any city using the wttr.in API.

Usage

For type reference see typedefs file or the documentation.

Requesting WeatherRequest object

import bttrwttrin

let weather: WeatherRequest = getWeather("Berlin")

Daily forecasts

import std/[options]
import bttrwttrin

let weather: WeatherRequest = getWeather("Berlin")

let today: WeatherForecast = get weather.getToday()
# This is equivalent to `weather.forecasts[0]`,
# but safer (no chance of `IndexDefect`), however
# it is your responsibility to handle `None` values!

let
    tomorrow: Option[WeatherForecast] = weather.getTomorrow()
    overmorrow: Option[WeatherForecast] = weather.getOvermorrow()

Current weather

import bttrwttrin

let
    weather: WeatherRequest = getWeather("Berlin")
    current: CurrentWeather = weather.current

# Temperature (has two fields for metric (°C) and imperial (°F))
let temperature: UnitData[int] = current.temperature

echo $temperature.metric & "°C"
echo $temperature.imperial & "°F"

Installation

Nimble

nimble install bttrwttrin (not yet included in package manager)

Building from source

git clone https://github.com/nirokay/bttrwttrin && cd bttrwttrin && nimble install