Fast, reliable currency conversion API with support for 51+ currencies and up-to-date exchange rates.
This API is available for public use without authentication. For better response times and enterprise applications, please contact our team for premium API access.
The CoreNexis Currency Converter API provides an easy way to convert between 51+ currencies with up-to-date exchange rates. This RESTful API is designed to be simple to use and integrate into any application.
The API consists of a single endpoint for currency conversion:
This endpoint accepts query parameters to specify the currencies and amount to convert. The response contains the converted amount, exchange rates used, and the date of the rates.
https://api.corenexis.com/convert-currency/?from=EUR&to=USD&amount=999
The API accepts the following query parameters:
Parameter | Type | Description |
---|---|---|
from Required | String | The source currency code (3-letter ISO code, e.g., USD, EUR, GBP) |
to Required | String | The target currency code (3-letter ISO code, e.g., USD, EUR, GBP) |
amount Required | Number | The amount to convert (must be a positive number) |
The API returns data in JSON format. A successful response will include the following properties:
{
"from": "EUR",
"to": "USD",
"amount": 999,
"converted_amount": 1074.19,
"rate_used": {
"EUR": 0.93,
"USD": 1
},
"ratetime": "2025-05-03 15:04:04"
}
Parameter | Type | Description |
---|---|---|
from | String | The source currency code used for conversion |
to | String | The target currency code used for conversion |
amount | Number | The original amount that was converted |
converted_amount | Number | The converted amount in the target currency |
rate_used | Object | The exchange rates used for the conversion, relative to USD (USD is always 1) |
ratetime | String | The date when the exchange rates were last updated (YYYY-MM-DD format) |
The API supports the following 51 currencies. You can use any of these currency codes in your requests:
Here are examples of how to use the API with various programming languages:
curl -X GET "https://api.corenexis.com/convert-currency/?from=EUR&to=USD&amount=999"
// Using fetch API
async function convertCurrency(fromCurrency, toCurrency, amount) {
try {
const response = await fetch(`https://api.corenexis.com/convert-currency/?from=${fromCurrency}&to=${toCurrency}&amount=${amount}`);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
return data;
} catch (error) {
console.error('Error converting currency:', error);
throw error;
}
}
// Example usage
convertCurrency('EUR', 'USD', 999)
.then(data => {
console.log(`${data.amount} ${data.from} = ${data.converted_amount} ${data.to}`);
console.log(`Exchange rate: 1 USD = ${data.rate_used[data.from]} ${data.from}`);
console.log(`Rate date: ${data.ratetime}`);
})
.catch(error => {
console.error('Conversion failed:', error);
});
import requests
def convert_currency(from_currency, to_currency, amount):
"""
Convert currency using CoreNexis Currency Converter API
Args:
from_currency (str): Source currency code (e.g., 'USD', 'EUR')
to_currency (str): Target currency code (e.g., 'USD', 'EUR')
amount (float): Amount to convert
Returns:
dict: API response with conversion details
"""
url = "https://api.corenexis.com/convert-currency/"
# Set up the query parameters
params = {
"from": from_currency,
"to": to_currency,
"amount": amount
}
# Make the API request
response = requests.get(url, params=params)
# Check if the request was successful
if response.status_code == 200:
return response.json()
else:
raise Exception(f"API request failed with status code: {response.status_code}")
# Example usage
try:
result = convert_currency("EUR", "USD", 999)
print(f"{result['amount']} {result['from']} = {result['converted_amount']} {result['to']}")
print(f"Exchange rate: 1 USD = {result['rate_used'][result['from']]} {result['from']}")
print(f"Rate date: {result['ratetime']}")
except Exception as e:
print(f"Error: {e}")
<?php
/**
* Convert currency using CoreNexis Currency Converter API
*
* @param string $fromCurrency Source currency code (e.g., 'USD', 'EUR')
* @param string $toCurrency Target currency code (e.g., 'USD', 'EUR')
* @param float $amount Amount to convert
* @return array|null API response with conversion details or null on error
*/
function convertCurrency($fromCurrency, $toCurrency, $amount) {
$url = "https://api.corenexis.com/convert-currency/";
// Build the query string
$queryString = http_build_query([
'from' => $fromCurrency,
'to' => $toCurrency,
'amount' => $amount
]);
// Set up cURL
$ch = curl_init($url . '?' . $queryString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check for errors
if (curl_errno($ch)) {
echo 'cURL Error: ' . curl_error($ch);
return null;
}
// Close cURL connection
curl_close($ch);
// Process the response
if ($httpCode == 200) {
return json_decode($response, true);
} else {
echo "API request failed with status code: $httpCode";
return null;
}
}
// Example usage
$result = convertCurrency('EUR', 'USD', 999);
if ($result) {
echo "{$result['amount']} {$result['from']} = {$result['converted_amount']} {$result['to']}\n";
echo "Exchange rate: 1 USD = {$result['rate_used'][$result['from']]} {$result['from']}\n";
echo "Rate date: {$result['ratetime']}\n";
} else {
echo "Conversion failed.\n";
}
The API uses standard HTTP status codes to indicate the success or failure of a request. Here are the common error responses you might encounter:
Status Code | Description | Example Response |
---|---|---|
400 | Bad Request - Missing required parameters | {"error": "Missing required parameter: amount"} |
400 | Bad Request - Invalid currency code | {"error": "Invalid currency code: XYZ"} |
400 | Bad Request - Invalid amount | {"error": "Amount must be a positive number"} |
500 | Internal Server Error - Something went wrong on our end | {"error": "Internal server error"} |
Here are some recommendations for handling errors in your application:
If you need help with our API or want to upgrade to a premium plan, we're here to help.
For better response times and enterprise applications requiring SLA guarantees, please contact our team to discuss your needs and get premium API access.