The Currency Conversion API provides real-time exchange rates between USD (United States Dollar) and GBP (British Pound Sterling). This API allows you to:
The API uses up-to-date exchange rates and provides instant conversions between these two major world currencies.
https://api.api-ninjas.com/v1/convertcurrency
have
requiredCurrency you currently hold. Must be either USD
or GBP
.
want
requiredCurrency you want to convert to. Must be either USD
or GBP
.
amount
requiredAmount of currency to convert.
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/convertcurrency?have=USD&want=GBP&amount=1000
1
2
3
4
5
6
{
"old_amount": 1000,
"old_currency": "USD",
"new_currency": "GBP",
"new_amount": 789.54
}
1
2
3
4
5
6
7
8
import requests
api_url = 'https://api.api-ninjas.com/v1/convertcurrency?have=USD&want=GBP&amount=1000'
response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'})
if response.status_code == requests.codes.ok:
print(response.text)
else:
print("Error:", response.status_code, response.text)
If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.