This endpoint is used to convert an amount of money from one currency to another. It retrieves the latest exchange rates and calculates the equivalent amount in the target currency.
Method: GET
Query Parameters:
amount
(required): The amount of money to be converted. This should be a numeric value.source_currency
(required): The currency code of the currency you are converting from. This should be a 3-letter ISO currency code (e.g., USD, EUR).target_currency
(required): The currency code of the currency you are converting to. This should be a 3-letter ISO currency code (e.g., USD, EUR).
Example Request
cURL
curl -X GET 'https://node.nodetrigger.com/convert-currency?amount=100&source_currency=USD&target_currency=EUR'
JavaScript (fetch)
fetch('https://node.nodetrigger.com/convert-currency?amount=100&source_currency=USD&target_currency=EUR')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Response
amount
: The original amount requested for conversion.source_currency
: The currency code of the original currency.target_currency
: The currency code of the target currency.converted_amount
: The converted amount in the target currency.
Response Example
{
"amount": 100,
"source_currency": "USD",
"target_currency": "EUR",
"converted_amount": 85.50
}
Real Life Examples
Example 1: Converting USD to EUR
Request:
curl -X GET 'https://node.nodetrigger.com/convert-currency?amount=200&source_currency=USD&target_currency=EUR'
Response:
{
"amount": 200,
"source_currency": "USD",
"target_currency": "EUR",
"converted_amount": 171.00
}
Example 2: Converting GBP to JPY
Request:
curl -X GET 'https://node.nodetrigger.com/convert-currency?amount=50&source_currency=GBP&target_currency=JPY'
Response:
{
"amount": 50,
"source_currency": "GBP",
"target_currency": "JPY",
"converted_amount": 7500.00
}