Currency conversion
curl --request GET \
--url 'https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}' \
--header 'api-key: <api-key>'import requests
url = "https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}"
headers = {"api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'api-key': '<api-key>'}};
fetch('https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}")
.header("api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"info": {
"timestamp": "1766937316.276",
"rate": 1.17697
},
"query": {
"to": "USD",
"amount": 10,
"from": "EUR"
},
"result": 11.7697
}
Currency Tools
Currency conversion
GET
convert?amount=
{amount}
&from=
{from}
&to=
{to}
Currency conversion
curl --request GET \
--url 'https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}' \
--header 'api-key: <api-key>'import requests
url = "https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}"
headers = {"api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'api-key': '<api-key>'}};
fetch('https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}")
.header("api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xchangeapi.com/convert?amount={amount}&from={from}&to={to}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"info": {
"timestamp": "1766937316.276",
"rate": 1.17697
},
"query": {
"to": "USD",
"amount": 10,
"from": "EUR"
},
"result": 11.7697
}
Convert a specific amount from one currency to another using the latest available exchange rates. This endpoint performs real-time currency conversion calculations, making it easy to handle cross-currency transactions in your application.
The returned data includes the timestamp of the conversion rate used, ensuring transparency for financial calculations.
Note on Precision: Some currency pairs are returned with a multiplier (e.g., 100 or 1000) to ensure high precision.
Query parameters
string
required
The 3-letter currency code of the source currency (e.g.,
USD, EUR). See the list of available pairs.string
required
The 3-letter currency code of the target currency (e.g.,
GBP, JPY). See the list of available pairs.decimal
required
The value to convert.
Response
object
object
string
The calculated converted amount.
{
"info": {
"timestamp": "1766937316.276",
"rate": 1.17697
},
"query": {
"to": "USD",
"amount": 10,
"from": "EUR"
},
"result": 11.7697
}
Was this page helpful?
