Ruby Currency Converter

PHOTO EMBED

Tue Aug 08 2023 08:05:07 GMT+0000 (Coordinated Universal Time)

Saved by @martechdev #ruby ##currencyconverter

require 'net/http'
require 'json'

url = "https://api.currencyapi.com/v3/latest?apikey=YOUR-API-KEY"
uri = URI(url)
response = Net::HTTP.get(uri)
response_obj = JSON.parse(response)

rate = response_obj['data']
content_copyCOPY

This snippet was copied from the currencyapi.com documentation. For Ruby, they specifically provide a snippet using a standard HTTP client.

https://currencyapi.com/docs/examples/ruby-currency-converter