No description
Find a file
2024-02-06 10:37:13 +01:00
.vscode added tests (not passing) and implemented objects with conversions (broken) 2024-01-25 11:51:46 +01:00
src documentation 2024-02-06 09:58:39 +01:00
tests added more QoL procs 2024-02-06 09:33:33 +01:00
.gitignore documentation 2024-02-06 10:37:13 +01:00
bttrwttrin.nimble added more QoL procs 2024-02-06 09:33:33 +01:00
README.md documentation 2024-02-06 10:37:13 +01:00

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