#!/usr/bin/env nu # TODO: include fallback to alternate URL: https://latest.currency-api.pages.dev/v1 let base_url = 'https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1' # Convert one unit of a currency to another using the following API: # https://github.com/fawazahmed0/exchange-api def main [target:string = "usd" # Unit of curency to convert to source:string = "eur" # Base currency to convert from ] { $"((http get $"($base_url)/currencies/($source).json") | get $source | get $target)\n" } # Lists all available currencies def "main list" [ ] { http get $"($base_url)/currencies.json" }