Getting started overview
Integrating with Exchangerate.host involves a few distinct steps to ensure you can reliably fetch currency exchange rate data. This guide focuses on efficiently moving from account creation to a successful API call. The process includes signing up for an account, understanding the role of API keys (though optional for the free tier, they provide better tracking and are required for higher usage), and making your first request to the API's endpoints.
Exchangerate.host provides a free tier offering 2,000 requests per month, which is suitable for initial development and testing. For higher volume or production environments, paid plans are available, starting at $9.99 per month for 10,000 requests, and scaling up to 1,000,000 requests per month for $99.99, as detailed on the Exchangerate.host pricing page.
The API supports both JSON and XML response formats and utilizes HTTPS for all requests to ensure data security. The comprehensive Exchangerate.host documentation offers detailed explanations of all available endpoints and parameters.
Here’s a quick reference to the essential steps for getting started:
| Step | What to do | Where |
|---|---|---|
| 1. Sign Up | Create a free account | Exchangerate.host website |
| 2. Get API Key | Locate or generate your API access key | Exchangerate.host dashboard (after signup) |
| 3. Make Request | Execute a cURL command to fetch data | Your terminal or preferred API client |
| 4. Parse Response | Process the JSON or XML data | Your application's code |
Create an account and get keys
To begin using Exchangerate.host, you need to sign up for an account. While the API can be accessed without an explicit API key for certain free-tier requests, creating an account and obtaining a key is recommended for tracking usage and is mandatory for accessing higher-tier features and increased request limits. The API key ensures that your requests are associated with your account, allowing for proper billing and access management.
- Navigate to the Exchangerate.host homepage: Open your web browser and go to Exchangerate.host's official website.
- Sign up for a new account: Look for a 'Sign Up' or 'Get API Key' button. You will typically be prompted to enter your email address and create a password.
- Verify your email: After signing up, Exchangerate.host will likely send a verification email to the address you provided. Follow the instructions in the email to confirm your account.
- Access your dashboard: Once your account is verified, log in to your Exchangerate.host dashboard.
- Locate your API Key: Within your dashboard, there will be a section dedicated to your API key. This key is a unique string of characters that authenticates your requests to the API. Copy this key, as you will need it for making authenticated API calls. Keep your API key secure and do not expose it in client-side code or public repositories. For server-side applications, consider using environment variables to store sensitive information like API keys, as recommended in general API key security practices.
It's important to note that for the free tier, Exchangerate.host allows usage without an API key for basic endpoints, but using a key is a good practice as it enables rate limit tracking specific to your account and prepares you for scaling to paid plans. For any paid plan, an API key is always required.
Your first request
Once you have your API key (or are ready to use the free tier without one for initial testing), you can make your first request. We will use the latest endpoint to fetch the latest exchange rates for a specified base currency. This example will use cURL, a command-line tool for making network requests, which is widely available on most operating systems.
Example 1: Fetching Latest Exchange Rates (without API key for free tier)
This request fetches the latest exchange rates with EUR as the base currency. For the free tier, an API key is often not strictly required for basic requests like this, though it's good practice to include it if you have one.
curl "https://api.exchangerate.host/latest?base=EUR"
A successful response will return a JSON object similar to this, containing the base currency, date, and a list of rates:
{
"motd": {
"msg": "If you or your company use this API, please consider supporting it by sending a donation to the author of the API. Thank you!",
"url": "https://exchangerate.host/#/donate"
},
"success": true,
"base": "EUR",
"date": "2023-10-27",
"rates": {
"AED": 3.905625,
"AFN": 80.208156,
"ALL": 105.109854,
// ... more rates ...
"ZWL": 362.000109
}
}
Example 2: Fetching Latest Exchange Rates (with API key for paid tier or tracked usage)
If you have an API key (e.g., YOUR_API_KEY) from your dashboard, you would typically include it as a query parameter in your requests, especially for paid plans or when you want to track your usage on the free tier.
curl "https://api.exchangerate.host/latest?base=USD&symbols=GBP,JPY&apikey=YOUR_API_KEY"
This request fetches the latest exchange rates for GBP and JPY, using USD as the base currency, and includes your API key for authentication/tracking.
Example 3: Fetching Historical Exchange Rates
To retrieve historical exchange rates, you can use the /YYYY-MM-DD endpoint. For instance, to get rates for October 26, 2023, with EUR as the base:
curl "https://api.exchangerate.host/2023-10-26?base=EUR"
The response structure will be similar to the latest rates, but with the specific historical date.
Example 4: Converting Currencies
The /convert endpoint allows you to convert a specific amount from one currency to another. This is particularly useful for financial applications needing direct conversions.
curl "https://api.exchangerate.host/convert?from=USD&to=JPY&amount=100"
This converts 100 USD to JPY. The response will include the conversion rate and the converted amount.
Common next steps
After successfully making your first API calls, consider these next steps for further integration and development:
- Explore Endpoints: Review the Exchangerate.host API documentation to understand all available endpoints, such as historical rates, specific currency conversions, and time-series data. Each endpoint has various parameters to refine your queries.
- Integrate into Your Application: Start integrating the API calls into your preferred programming language. Exchangerate.host provides examples in cURL, Python, PHP, and JavaScript, which can serve as a starting point.
- Handle Rate Limits: Be aware of the rate limits associated with your chosen plan. The free tier has a limit of 2,000 requests per month. Implement proper error handling for rate limit exceeded responses (HTTP 429 Too Many Requests) and consider implementing exponential backoff for retries to avoid overwhelming the API, a common practice in API error management.
- Secure Your API Key: If you are using an API key, ensure it is stored securely and not hardcoded directly into your application's source code, particularly in public repositories. Use environment variables or a secure configuration management system.
- Monitor API Usage: Utilize your Exchangerate.host dashboard to monitor your API usage and ensure you stay within your plan's limits. This helps in anticipating when an upgrade might be necessary.
- Implement Error Handling: Design your application to gracefully handle potential API errors, such as invalid parameters or unavailable services. The API typically returns descriptive error messages in JSON format.
- Consider Webhooks: While Exchangerate.host doesn't explicitly mention webhooks for rate changes in its public documentation, for applications requiring immediate notifications of significant currency fluctuations, explore if such a feature is available or consider polling the API at appropriate intervals based on your rate limits.
- Upgrade Your Plan: If your application requires more than 2,000 requests per month or needs premium features, consider upgrading to a paid plan.
Troubleshooting the first call
Encountering issues during your initial API call is common. Here's a guide to common problems and their solutions:
- "Invalid API Key" or "Authentication Failed" (HTTP 401/403):
- Check for typos: Ensure your API key is copied exactly as it appears in your Exchangerate.host dashboard.
- Missing API Key: Verify that you have included the
apikeyparameter in your request if you are using a paid plan or need usage tracking. Remember, some free tier requests do not strictly require an API key, but it is good practice to use it. - API Key activation: Confirm that your API key is active in your dashboard.
- "Rate Limit Exceeded" (HTTP 429):
- Check usage: Review your API usage in your Exchangerate.host dashboard. You might have exceeded the 2,000 requests/month limit on the free tier.
- Wait and retry: If you're hitting limits, wait for a short period before retrying. Implement exponential backoff in your application.
- Upgrade plan: If continuous high usage is required, consider upgrading your subscription plan to increase your request quota.
- "Invalid Base/Target Currency" or "Parameter Missing" (HTTP 400):
- Verify currency codes: Ensure that the currency codes (e.g.,
EUR,USD,JPY) are valid and correctly spelled. Refer to the Exchangerate.host documentation on supported currencies. - Check required parameters: Ensure all mandatory parameters for the specific endpoint you are calling (e.g.,
base,amountfor convert) are present.
- Verify currency codes: Ensure that the currency codes (e.g.,
- Network Connection Issues:
- Test connectivity: Ensure your machine has an active internet connection. Try pinging
api.exchangerate.host. - Firewall/Proxy: If you are in a corporate network, firewalls or proxy servers might be blocking outbound requests. Consult your network administrator.
- Test connectivity: Ensure your machine has an active internet connection. Try pinging
- No Response or Unexpected JSON:
- Verify URL: Double-check the endpoint URL for any typos.
- HTTP vs. HTTPS: Ensure you are using
https://for all requests, as Exchangerate.host requires secure connections. - JSON Parsing: If your application receives data but fails to parse it, verify that your JSON parser is correctly implemented and handles potential variations in the response structure. Look for an error message in the JSON payload itself.
- Outdated Data:
- Cache: If you are seeing old data, ensure your application or any proxies are not caching responses.
- Endpoint: Confirm you are calling the
/latestendpoint for current data, not a historical endpoint.
For persistent issues, the Exchangerate.host documentation is the primary resource for detailed error codes and usage examples. If problems persist, contacting Exchangerate.host support is the next step.