Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nirokay/bttrwttrin
Library to fetch weather for any city using [wttr.in](https://wttr.in/) API.
https://github.com/nirokay/bttrwttrin
lib library nim nim-lang nimble weather weather-api wttrin
Last synced: about 4 hours ago
JSON representation
Library to fetch weather for any city using [wttr.in](https://wttr.in/) API.
- Host: GitHub
- URL: https://github.com/nirokay/bttrwttrin
- Owner: nirokay
- Created: 2024-02-06T09:36:45.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-02-06T09:50:32.000Z (about 1 year ago)
- Last Synced: 2024-12-20T19:15:00.260Z (about 2 months ago)
- Topics: lib, library, nim, nim-lang, nimble, weather, weather-api, wttrin
- Language: Nim
- Homepage: https://nirokay.github.io/nim-docs/bttrwttrin/bttrwttrin.html
- Size: 160 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bttrwttrin
**Better wttr.in** is a library, that lets you easily request weather for any
city using the [wttr.in](https://wttr.in/) API.## Usage
For type reference see [typedefs file](./src/bttrwttrin/typedefs.nim) or the
[documentation](https://nirokay.github.io/nim-docs/bttrwttrin/bttrwttrin.html).### Requesting `WeatherRequest` object
```nim
import bttrwttrinlet weather: WeatherRequest = getWeather("Berlin")
```### Daily forecasts
```nim
import std/[options]
import bttrwttrinlet 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
```nim
import bttrwttrinlet
weather: WeatherRequest = getWeather("Berlin")
current: CurrentWeather = weather.current# Temperature (has two fields for metric (°C) and imperial (°F))
let temperature: UnitData[int] = current.temperatureecho $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`