README

XR-Sinatra is a simple currency exchange rate (Base USD only for now) API designed to display the current exchange rate selected as an image.

Usage

There are two endpoints currently:

  • Get currency exchange with USD base: Simply visit /:currency to receive a PNG image with the data. Example:
GET /COP - 200 OK # returns a image with the value.
  • Get currency exchange with other base: You can change the base currency used to perform the conversion using /:base/to/:currency. Example:
GET /EUR/to/COP - 200 OK # returns a image with the value.

Returns the exchange rate for 1 EUR to COP.

  • Get currency exchange with other base multiplied by amount: You can prefix an amount to base and it will multiply the result by that amount /:amount:base/to/:currency. Example:
GET /5EUR/to/COP - 200 OK # returns a image with the value.

Returns the exchange rate for 5 EUR to COP.

  • Output text instead of image: You can add a format suffix to the conversion endpoint like so /:amount:base/to/:currency.txt to receive a formatted text response instead of an image. Example:
GET /5EUR/to/COP.txt - 200 OK # returns text with the value.

Returns the exchange rate for 5 EUR to COP as a formatted text string.

Supported Currencies

This app connects to OXR. It supports the same supported currency rates:

["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", "BSD", "BTC", "BTN", "BWP", "BYN", "BYR", "BZD", "CAD", "CDF", "CHF", "CLF", "CLP", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EEK", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GGP", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP", "INR", "IQD", "IRR", "ISK", "JEP", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MTL", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VEF", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "YER", "ZAR", "ZMK", "ZMW", "ZWL"]