Overview
The Currency Converter API provides three main endpoints for currency operations. This guide demonstrates how to use each endpoint with practical examples.Base URL
All API requests use the following base URL:Replace
localhost:8000 with your actual deployment URL in production.Authentication
The Currency Converter API does not require authentication for requests. However, you must configure valid provider API keys in your environment variables for the service to function.Endpoints
Convert currency
Convert an amount from one currency to another using current exchange rates. Endpoint:GET /api/convert/{from_currency}/{to_currency}/{amount}
Parameters:
from_currency(string, required): Source currency code (3-5 characters)to_currency(string, required): Target currency code (3-5 characters)amount(decimal, required): Amount to convert (must be greater than 0)
from_currency: Source currency code usedto_currency: Target currency code usedoriginal_amount: Amount you requested to convertconverted_amount: Result after applying the exchange rateexchange_rate: Rate used for conversiontimestamp: When the rate was fetchedsource: Provider(s) that supplied the rate
Get exchange rate
Retrieve the current exchange rate between two currencies without performing a conversion. Endpoint:GET /api/rate/{from_currency}/{to_currency}
Parameters:
from_currency(string, required): Source currency code (3-5 characters)to_currency(string, required): Target currency code (3-5 characters)
from_currency: Source currency codeto_currency: Target currency coderate: Current exchange ratetimestamp: When the rate was fetchedsource: Provider(s) that supplied the rate
Rate fetching examples
Rate fetching examples
USD to EUR rate:GBP to CAD rate:EUR to CHF rate:
List supported currencies
Get a list of all currencies supported by the API. Endpoint:GET /api/currencies
Example request:
The supported currencies list represents the intersection of currencies available across all configured providers. This ensures every currency can be converted reliably.
Rate averaging explained
The Currency Converter API queries multiple providers simultaneously and averages their rates for accuracy.How it works
Parallel provider fetch
When you request a rate, the API queries all configured providers at once using
asyncio.gather():Filter successful responses
Failed requests are excluded from averaging:
- Provider timeouts
- API errors
- Network failures
Calculate average
The API computes the mean of successful rates:Example:
- Fixer.io returns:
1.2500 - OpenExchangeRates returns:
1.2520 - CurrencyAPI fails (timeout)
- Final rate:
(1.2500 + 1.2520) / 2 = 1.2510
Using with programming languages
Python
JavaScript
Node.js
Go
Best practices
Cache responses on your end
Cache responses on your end
While the API caches rates for 5 minutes, you should implement your own caching layer if making frequent requests:
Handle errors gracefully
Handle errors gracefully
Always check response status codes and handle errors:
Validate currency codes first
Validate currency codes first
Before making conversion requests, fetch the supported currencies list and validate against it:
Use uppercase currency codes
Use uppercase currency codes
While the API automatically converts currency codes to uppercase, send them in uppercase for consistency:
API documentation
The Currency Converter API provides interactive documentation:- Swagger UI:
http://localhost:8000/docs- Test endpoints directly in your browser - ReDoc:
http://localhost:8000/redoc- Read-only documentation with examples
Use the Swagger UI to explore endpoints, view request/response schemas, and test API calls without writing code.
Next steps
- Learn about error handling and status codes
- Understand the caching strategy for optimal performance
