Get Instant Access to our Exchange Rates API

Get access instantly - 1000 requests free p/m.


How To Use Our Ruby on Rails Currency API

We offer an easy to use, accurate and reliable exchange rates API for Ruby that's perfect for both personal and professional use.

Fetching exchange rates using our Ruby currency conversion API is as easy as making GET requests. This means you can easily integrate our API into your Ruby on Rails project however you'd prefer.

For more details on the different types of request we support please see our Main Documentation.

Alternatively simply use the Ruby library code below to get started with our exchange rate data as fast as you can copy & paste!

Simple Python Currency Conversion Example


require 'net/http'
require 'json'

# Setting URL
url = "https://v3.exchangerate-api.com/bulk/YOUR-API-KEY/USD"
uri = URI(url)
response = Net::HTTP.get(uri)
response_obj = JSON.parse(response)

# Getting rate
rate = response_obj['rates']['EUR']
				

This will return the exchange rates from USD to all other currencies we support:

{
	"result": "success",
	"from": "USD",
	"rates": {
		"AUD": ((AUD in terms of USD)),
		"BGN": 1.8096,
		"BRL": 3.1143,
		"...": 1.3113,
		"...": 7.473, etc. etc.
	}
}

Please see our main documentation for further information on this query type & error response details.



We also offer automatic localization requests:



Automatic Currency Localization for Java

This example relies on Google's GSON library.


require 'net/http'
require 'json'

# Getting visitor IP address
ip = request.remote_ip

# Setting URL
url = "https://v3.exchangerate-api.com/local/YOUR-API-KEY/USD" + ip
uri = URI(url)
response = Net::HTTP.get(uri)
response_obj = JSON.parse(response)

# Getting rate
rate = response_obj['rate']
				

This will return the exchange rate from your base currency to the visitor currency & i18n data on your visitor.

In the example API response below your prices are in USD and a customer was visiting from a Bulgarian IP address so BGN is returned as the appropriate currency for a Bulgarian visitor.

{
	"result": "success",
	"from": "USD",
	"to": "BGN",
	"country_code": "BG",
	"currency_symbol": "43b,432",
	"rate": 1.81
}

Please see our main documentation for further information on this query type & error response details.

Additionally, please email us if you'd like to submit a better code example, we'll credit you!