### Example API Request for Latest Rates (HTTP) Source: https://docs.openexchangerates.org/reference/index This is an example of a basic HTTP GET request to retrieve the latest exchange rates relative to a specified base currency. It requires a valid application ID. The response will be in JSON format. ```HTTP https://openexchangerates.org/api/latest.json?app_id=YOUR_APP_ID ``` -------------------------------- ### Time-Series Endpoint Example (HTTP) Source: https://docs.openexchangerates.org/reference/time-series-json This snippet demonstrates how to make a request to the time-series endpoint using HTTP. It includes parameters for your application ID, start and end dates, base currency, target symbols, and pretty printing the output. ```http https://openexchangerates.org/api/time-series.json ?app_id=YOUR_APP_ID &start=2012-01-01 &end=2012-01-31 &base=AUD &symbols=BTC,EUR,HKD &prettyprint=1 ``` -------------------------------- ### Currency Conversion Example (jQuery) Source: https://docs.openexchangerates.org/reference/convert Illustrates currency conversion using the Open Exchange Rates API with jQuery in JavaScript. This example fetches conversion data and logs it to the console. An application ID is necessary for the request. ```javascript var from = "GBP", to = "EUR", value = "19999.95"; $.get('https://openexchangerates.org/api/convert/' + value + '/' + from + '/' + to, {app_id: 'YOUR_APP_ID'}, function(data) { console.log(data); }); ``` -------------------------------- ### API Base URL and Endpoint Examples (HTTP) Source: https://docs.openexchangerates.org/reference/index Demonstrates the base URL for the Open Exchange Rates API and provides examples of common endpoints like latest rates, currency lists, and historical data. ```http https://openexchangerates.org/api/ latest.json currencies.json historical/2013-02-16.json ``` -------------------------------- ### Construct API Request with Multiple Parameters Source: https://docs.openexchangerates.org/reference/alternative-currencies This example demonstrates how to construct an HTTP GET request to the latest.json endpoint of the Open Exchange Rates API. It shows how to combine the 'base' currency, 'show_alternative' flag, and 'symbols' parameter to retrieve specific alternative and digital currency rates. Replace 'YOUR_APP_ID' with your actual API key. ```http https://openexchangerates.org/api/latest.json ?app_id=YOUR_APP_ID &base=LTC &show_alternative=1 &symbols=ETH,VEF,VEF_DIPRO,VEF_DICOM,VEF_BLKMKT,BTC,NEM &prettyprint=0 ``` -------------------------------- ### Currency Conversion Example (HTTP) Source: https://docs.openexchangerates.org/reference/convert Demonstrates how to perform currency conversion using the Open Exchange Rates API via an HTTP request. Requires a valid application ID. ```http https://openexchangerates.org/api/convert/19999.95/GBP/EUR?app_id=YOUR_APP_ID ``` -------------------------------- ### Fetch Historical Exchange Rates (HTTP) Source: https://docs.openexchangerates.org/reference/historical-json This example demonstrates how to fetch historical currency exchange rates using an HTTP GET request. It requires a valid application ID and specifies the desired date for the historical data. ```http https://openexchangerates.org/api/historical/2012-07-10.json?app_id=YOUR_APP_ID ``` -------------------------------- ### Example OHLC API Request Source: https://docs.openexchangerates.org/reference/ohlc-json Demonstrates how to construct a request URL for the OHLC API endpoint. This example fetches data for a 30-minute period starting at a specific UTC timestamp, with USD as the base currency and includes alternative currency symbols. ```http GET https://openexchangerates.org/api/ohlc.json ?app_id=YOUR_APP_ID &start=2017-07-17T08:30:00Z &period=30m &base=USD &symbols=XAU,XAG,XPD,XPT &show_alternative=true &prettyprint=true ``` -------------------------------- ### Fetch Bid-Ask Rates using jQuery AJAX Source: https://docs.openexchangerates.org/reference/bid-ask-prices Provides a JavaScript example using jQuery's `$.get` method to request bid-ask prices from the API. It logs the entire response data to the console. The `show_alternative: 1` parameter in the example seems to be a typo and should likely be `show_bid_ask: 1` based on the context. ```javascript $.get('https://openexchangerates.org/api/latest.json', {app_id: 'YOUR_APP_ID', show_alternative: 1}, function(data) { console.log(data); }); ``` -------------------------------- ### Example JSON Response for Latest Rates Source: https://docs.openexchangerates.org/reference/index This is an example of a JSON response for a 'latest.json' API request. It includes a disclaimer, license link, a UNIX timestamp, the base currency, and a 'rates' object containing currency codes and their corresponding values relative to the base currency. ```JSON { "disclaimer": "https://openexchangerates.org/terms/", "license": "https://openexchangerates.org/license/", "timestamp": 1449877801, "base": "USD", "rates": { "AED": 3.672538, "AFN": 66.809999, "ALL": 125.716501, "AMD": 484.902502, "ANG": 1.788575, "AOA": 135.295998, "ARS": 9.750101, "AUD": 1.390866, "/* ... */" } } ``` -------------------------------- ### Get Historical Exchange Rates (Time Series JSON) Source: https://docs.openexchangerates.org/reference/time-series-json Retrieves historical exchange rates for a given time period using the time series bulk download API endpoint. This functionality is available for Enterprise and Unlimited plan clients. Requires an `app_id`, `start` date, and `end` date. Optional parameters include `symbols`, `base` currency, `show_alternative`, and `prettyprint` for formatting. ```json { "openapi": "3.1.0", "info": { "title": "api-settings", "version": "0.7" }, "servers": [ { "url": "https://openexchangerates.org/api" } ], "components": { "securitySchemes": { "sec0": { "type": "apiKey", "name": "app_id", "in": "query", "x-default": "" } } }, "security": [ { "sec0": [] } ], "paths": { "/time-series.json": { "get": { "summary": "/time-series.json", "description": "Get historical exchange rates for a given time period, where available, using the time series / bulk download API endpoint. Please read all the details before integrating.\n\nTime Series requests are currently available for clients on the Enterprise and Unlimited plans.", "operationId": "time-series-json", "parameters": [ { "name": "app_id", "in": "query", "description": "Your unique App ID", "schema": { "type": "string", "default": "Required" } }, { "name": "start", "in": "query", "description": "The time series start date in YYYY-MM-DD format", "schema": { "type": "string", "format": "date", "default": "Required" } }, { "name": "end", "in": "query", "description": "The time series end date in YYYY-MM-DD format (see notes)", "schema": { "type": "string", "format": "date", "default": "Required" } }, { "name": "symbols", "in": "query", "description": "Limit results to specific currencies (comma-separated list of 3-letter codes)", "schema": { "type": "string", "default": "Recommended" } }, { "name": "base", "in": "query", "description": "Change base currency (3-letter code, default: USD)", "schema": { "type": "string", "default": "Optional" } }, { "name": "show_alternative", "in": "query", "description": "Extend returned values with alternative, black market and digital currency rates", "schema": { "type": "boolean", "default": false } }, { "name": "prettyprint", "in": "query", "description": "Human-readable response for debugging (response size will be much larger)", "schema": { "type": "boolean", "default": false } } ], "responses": { "200": { "description": "200", "content": { "application/json": { "examples": { "Result": { "value": "{\n \"disclaimer\": \"https://openexchangerates.org/terms/\",\n \"license\": \"https://openexchangerates.org/license/\",\n \"start_date\": \"2013-01-01\",\n \"end_date\": \"2013-01-31\",\n \"base\": \"AUD\",\n \"rates\": {\n \"2013-01-01\": {\n \"BTC\": 0.0778595876,\n \"EUR\": 0.785518,\n \"HKD\": 8.04136\n },\n \"2013-01-02\": {\n \"BTC\": 0.0789400739,\n \"EUR\": 0.795034,\n \"HKD\": 8.138096\n },\n \"2013-01-03\": {\n \"BTC\": 0.0785299961,\n \"EUR\": 0.80092,\n \"HKD\": 8.116954\n },\n \"/* ... */\n }\n}" } } } } }, "400": { "description": "400", "content": { "application/json": { "examples": { "Bad Request (not_available)": { "value": "{\n \"error\": true,\n \"status\": 400,\n \"message\": \"not_available\",\n \"description\": \"Historical rates for one or more of your requested dates are not available - please try a different date-range, or contact support@openexchangerates.org.\"\n}" }, "Bad Request (invalid_date_range)": { "value": "{\n \"error\": true,\n \"status\": 400,\n \"message\": \"invalid_date_range\",\n \"description\": \"Invalid date range: `start` and `end` dates must be valid days, in the format 'YYYY-MM-DD'.\"\n}" } }, "schema": { "oneOf": [ { "title": "Bad Request (not_available)", "type": "object", "properties": { "error": { "type": "boolean" }, "status": { "type": "integer" }, "message": { "type": "string" }, "description": { "type": "string" } } }, { "title": "Bad Request (invalid_date_range)", "type": "object", "properties": { "error": { "type": "boolean" }, "status": { "type": "integer" }, "message": { "type": "string" }, "description": { "type": "string" } } } ] } } } } } } } } } ``` -------------------------------- ### Time-Series Endpoint Example (JavaScript) Source: https://docs.openexchangerates.org/reference/time-series-json This JavaScript code snippet utilizes jQuery to fetch time-series exchange rate data. It constructs the necessary query parameters and logs the received data to the console. ```javascript var query_vars = { app_id: 'YOUR_APP_ID', start: '2012-01-01', end: '2012-01-31', base: 'AUD', symbols: 'BTC,EUR,HKD', prettyprint: 1 } $.get('https://openexchangerates.org/api/time-series.json', query_vars, function(data) { console.log(data); }); ``` -------------------------------- ### Combining Parameters for Latest Rates Source: https://docs.openexchangerates.org/reference/alternative-currencies This example shows how to combine multiple parameters, including base currency, alternative rates, specific symbols, and output formatting, for the latest.json endpoint. ```APIDOC ## GET /api/latest.json (Advanced Parameters) ### Description Fetches the latest foreign exchange rates, allowing for advanced parameter combinations such as specifying a base currency, including alternative rates, selecting specific target currencies, and controlling output formatting. ### Method GET ### Endpoint https://openexchangerates.org/api/latest.json ### Query Parameters - **app_id** (string) - Required - Your unique application ID. - **base** (string) - Optional - The base currency code (default is USD). - **show_alternative** (boolean) - Optional - Set to 1 to include alternative rates. - **symbols** (string) - Optional - A comma-separated list of currency codes to limit the response to. - **prettyprint** (boolean) - Optional - Set to 0 for a compact JSON output. ### Request Example ```http https://openexchangerates.org/api/latest.json ?app_id=YOUR_APP_ID &base=LTC &show_alternative=1 &symbols=ETH,VEF,VEF_DIPRO,VEF_DICOM,VEF_BLKMKT,BTC,NEM &prettyprint=0 ``` ### Response #### Success Response (200) - **rates** (object) - An object containing currency exchange rates based on the specified parameters. #### Response Example ```json { "rates": { "ETH": 0.05, "VEF": 50000, "VEF_DIPRO": 60000, "VEF_DICOM": 70000, "VEF_BLKMKT": 100000, "BTC": 0.001, "NEM": 10 } } ``` ``` -------------------------------- ### GET /convert/{value}/{from}/{to} Source: https://docs.openexchangerates.org/reference/convert Convert any money value from one currency to another at the latest API rates. This endpoint uses a REST-based approach and an alternate response format. Currency conversion requests are available for clients on the Unlimited plan. ```APIDOC ## GET /convert/{value}/{from}/{to} ### Description Convert any money value from one currency to another at the latest API rates using the /convert API endpoint. This feature works differently to other endpoints in our API, using a REST-based approach and an alternate response format. Currency conversion requests are currently available for clients on the Unlimited plan. ### Method GET ### Endpoint https://openexchangerates.org/api/convert/{value}/{from}/{to} ### Parameters #### Path Parameters - **value** (integer) - Required - The value to be converted - **from** (string) - Required - The base ('from') currency (3-letter code) - **to** (string) - Required - The target ('to') currency (3-letter code) #### Query Parameters - **app_id** (string) - Required - Your unique App ID - **prettyprint** (boolean) - Optional - Human-readable response for debugging ### Request Example ```json { "example": "GET https://openexchangerates.org/api/convert/19999.95/GBP/EUR?app_id=YOUR_APP_ID" } ``` ### Response #### Success Response (200) - **disclaimer** (string) - URL to terms and conditions. - **license** (string) - URL to license information. - **request** (object) - Details about the conversion request. - **query** (string) - The query string used for the request. - **amount** (number) - The value that was converted. - **from** (string) - The base currency. - **to** (string) - The target currency. - **meta** (object) - Metadata about the conversion. - **timestamp** (integer) - The timestamp of the exchange rate. - **rate** (number) - The exchange rate used for conversion. - **response** (number) - The converted value. #### Response Example ```json { "disclaimer": "https://openexchangerates.org/terms/", "license": "https://openexchangerates.org/license/", "request": { "query": "/convert/19999.95/GBP/EUR", "amount": 19999.95, "from": "GBP", "to": "EUR" }, "meta": { "timestamp": 1449885661, "rate": 1.383702 }, "response": 27673.975864 } ``` ``` -------------------------------- ### Fetch Latest Exchange Rates (HTTP/JavaScript) Source: https://docs.openexchangerates.org/reference/latest-json This snippet demonstrates how to fetch the latest exchange rates using the Open Exchange Rates API. It includes an example using a direct HTTP request and a JavaScript example using jQuery. Ensure you replace 'YOUR_APP_ID' with your actual application ID. ```http https://openexchangerates.org/api/latest.json?app_id=YOUR_APP_ID ``` ```javascript $.get('https://openexchangerates.org/api/latest.json', {app_id: 'YOUR_APP_ID'}, function(data) { console.log(data); }); ``` -------------------------------- ### Get List Of Available Alternative Currencies Source: https://docs.openexchangerates.org/reference/alternative-currencies Add the `show_alternative=1` parameter to the `currencies.json` endpoint to retrieve a list of all supported alternative currency symbols and their full names. ```APIDOC ## GET /api/currencies.json ### Description Retrieves a list of all supported currencies, including alternative, black market, and digital currencies when `show_alternative=1` is appended. ### Method GET ### Endpoint /api/currencies.json ### Query Parameters - **show_alternative** (integer) - Optional - Set to `1` to include alternative currency symbols and names. ### Request Example ```http https://openexchangerates.org/api/currencies.json ?show_alternative=1 ``` ### Response #### Success Response (200) - **currency_symbol** (string) - The currency symbol (may include alternative formats like "VEF_BLKMKT"). - **currency_name** (string) - The full name of the currency. #### Response Example ```json { "AED": "United Arab Emirates Dirham", "AFN": "Afghan Afghani", "VEF_BLKMKT": "Venezuelan Bolívar (Black Market)", "VEF_DICOM": "Venezuelan Bolívar (DICOM Rate)" } ``` ``` -------------------------------- ### Example API Response Headers for ETags Source: https://docs.openexchangerates.org/reference/etags Illustrates the 'Date' and 'ETag' headers typically returned in an API response. These values are crucial for implementing client-side caching mechanisms. ```http Date: Thu, 20 Dec 2012 14:48:28 GMT ETag: "4e6acdd9fea30c21d9bdf1925afbf846" ``` -------------------------------- ### GET /usage.json Source: https://docs.openexchangerates.org/reference/usage-json Retrieves basic plan information and usage statistics for your Open Exchange Rates App ID. ```APIDOC ## GET /usage.json ### Description Get basic plan information and usage statistics for an Open Exchange Rates App ID. ### Method GET ### Endpoint https://openexchangerates.org/api/usage.json ### Parameters #### Query Parameters - **app_id** (string) - Required - Your unique App ID. - **prettyprint** (boolean) - Optional - Set to 'false' to minify the response. Defaults to true. ### Request Example ```json { "app_id": "YOUR_APP_ID", "prettyprint": true } ``` ### Response #### Success Response (200) - **status** (integer) - The status code of the response. - **data** (object) - Contains plan and usage details. - **app_id** (string) - Your unique App ID. - **status** (string) - The status of your account (e.g., 'active'). - **plan** (object) - Details about your current plan. - **name** (string) - The name of the plan (e.g., 'Enterprise'). - **quota** (string) - The request quota for the plan (e.g., '100,000 requests/month'). - **update_frequency** (string) - How often the exchange rates are updated (e.g., '30-minute'). - **features** (object) - Available features for the plan. - **base** (boolean) - Whether base currency support is included. - **symbols** (boolean) - Whether symbol support is included. - **experimental** (boolean) - Whether experimental features are included. - **time-series** (boolean) - Whether time-series data access is included. - **convert** (boolean) - Whether currency conversion is included. - **usage** (object) - Your current API usage statistics. - **requests** (integer) - The number of requests made. - **requests_quota** (integer) - The total request quota for the month. - **requests_remaining** (integer) - The number of requests remaining for the month. - **days_elapsed** (integer) - The number of days elapsed in the current billing cycle. - **days_remaining** (integer) - The number of days remaining in the current billing cycle. - **daily_average** (integer) - The average number of requests per day. #### Response Example ```json { "status": 200, "data": { "app_id": "YOUR_APP_ID", "status": "active", "plan": { "name": "Enterprise", "quota": "100,000 requests/month", "update_frequency": "30-minute", "features": { "base": true, "symbols": true, "experimental": true, "time-series": true, "convert": false } }, "usage": { "requests": 54524, "requests_quota": 100000, "requests_remaining": 45476, "days_elapsed": 16, "days_remaining": 14, "daily_average": 2842 } } } ``` ``` -------------------------------- ### Get All Currencies (jQuery) Source: https://docs.openexchangerates.org/reference/currencies-json Fetches a JSON list of all available currency symbols and their full names using jQuery's AJAX get method. The response is a JSON object where keys are currency codes and values are currency names. This example demonstrates basic usage and logging a specific currency's name. ```javascript $.get('https://openexchangerates.org/api/currencies.json', function(data) { console.log("Did you know? One unit of VND is known as a '" + data.VND + "'"); }); ``` -------------------------------- ### API Request with Query Parameters (HTTP) Source: https://docs.openexchangerates.org/reference/index Illustrates how to construct an API request URL by appending query parameters such as App ID, base currency, and JSONP callback function. ```http https://openexchangerates.org/api/latest.json ?app_id=YOUR_APP_ID &base=GBP &callback=someCallbackFunction ``` -------------------------------- ### JSON Response with Specific Currencies and Callback Source: https://docs.openexchangerates.org/reference/get-specific-currencies This is an example of a JSONP response from the Open Exchange Rates API when using the 'symbols', 'base', and 'callback' parameters. The data is wrapped in a JavaScript function call. ```json someFunctionName( { disclaimer: "https://openexchangerates.org/terms/", license: "https://openexchangerates.org/license/", timestamp: 1424127600, base: "CAD", rates: { AUD: 1.032828, EUR: 0.706867, GBP: 0.522328, } } ) ``` -------------------------------- ### Combine Symbols with Base and Callback (HTTP) Source: https://docs.openexchangerates.org/reference/get-specific-currencies This HTTP request example shows how to combine the 'symbols' parameter with other API parameters like 'base' to change the base currency and 'callback' for JSONP responses. It's applicable to historical data requests as well. ```http https://openexchangerates.org/api/historical/2015-02-16.json ?app_id=[[app:app_id]] &base=CAD &symbols=AUD,GBP,EUR &callback=someFunctionName ``` -------------------------------- ### Request Specific Currencies (HTTP) Source: https://docs.openexchangerates.org/reference/get-specific-currencies This example demonstrates how to make an HTTP request to the Open Exchange Rates API to retrieve exchange rates for a specified list of currencies using the 'symbols' query parameter. The response contains rates relative to the 'base' currency. ```http https://openexchangerates.org/api/latest.json ?app_id=[[app:app_id]] &symbols=GBP,EUR,AED,CAD ``` -------------------------------- ### Connecting To The API Source: https://docs.openexchangerates.org/reference/index Accesses the API via simple HTTPS requests, returning data in JSON format. Supports various integration libraries and requires direct requests for fresh data. ```APIDOC ## Connecting To The API We serve our data in JSON format via a simple URL-based interface over HTTPS, which enables you to use the rates in whichever way you require. **Connection Types** Any language or software that can make HTTP requests or fetch web addresses can access our API (for example, you can visit any of the API routes in your browser to verify they’re working as expected). For your integration, you can use whichever library you require. This will vary depending on your development environment. There are guides and a wide range of open source integrations available, also covered in our documentation. URLs (routes) are requested once over HTTPS, and deliver all their data in one go, just like a normal web request. We do not currently support websockets, webhooks or any other keep-alive or push-notification style connections – in other words, when you want fresh data, you simply request it from our server. We're considering these methods for a future version of our API, so please email us if interested. **URL Format** The API base path is `https://openexchangerates.org/api/`. API routes/endpoints are then appended to this base path, like so: ```http https://openexchangerates.org/api/ latest.json currencies.json historical/2013-02-16.json ``` Query parameters (such as your App ID, requested base currency, or JSONP callback) are appended as GET request parameters, for example: ```http https://openexchangerates.org/api/latest.json ?app_id=YOUR_APP_ID &base=GBP &callback=someCallbackFunction ``` If your request is valid and permitted, you will receive a JSON-formatted response to work with. If something is wrong with the request, you will receive an error message. ``` -------------------------------- ### GET /api/historical/{date}.json with Symbols and Base Currency Source: https://docs.openexchangerates.org/reference/get-specific-currencies Retrieve historical exchange rates for a specific date for a subset of currencies, and specify a base currency other than the default. ```APIDOC ## GET /api/historical/{date}.json?base=CAD&symbols=AUD,GBP,EUR ### Description Retrieves historical exchange rates for a specified date, allowing you to define a base currency and a subset of target currencies. ### Method GET ### Endpoint /api/historical/{date}.json ### Parameters #### Path Parameters - **date** (string) - Required - The date for which to retrieve historical rates (YYYY-MM-DD format). #### Query Parameters - **app_id** (string) - Required - Your unique application ID. - **base** (string) - Optional - The base currency against which to calculate rates (default is USD). - **symbols** (string) - Optional - A comma-separated list of 3-letter ISO currency codes to include in the response. - **callback** (string) - Optional - A JavaScript function name for JSONP responses. ### Request Example ```http https://openexchangerates.org/api/historical/2015-02-16.json?app_id=[[app:app_id]]&base=CAD&symbols=AUD,GBP,EUR&callback=someFunctionName ``` ### Response #### Success Response (200) - **disclaimer** (string) - Information regarding the terms of use. - **license** (string) - Information regarding the license. - **timestamp** (integer) - The time at which the rates were generated. - **base** (string) - The base currency against which rates are provided. - **rates** (object) - An object containing currency codes as keys and their corresponding exchange rates as values. #### Response Example ```json someFunctionName( { "disclaimer": "https://openexchangerates.org/terms/", "license": "https://openexchangerates.org/license/", "timestamp": 1424127600, "base": "CAD", "rates": { "AUD": 1.032828, "EUR": 0.706867, "GBP": 0.522328 } } ) ``` ``` -------------------------------- ### API Introduction Source: https://docs.openexchangerates.org/reference/index Open Exchange Rates provides a simple JSON API for live and historical foreign exchange rates, blended from multiple reliable sources. ```APIDOC ## API Introduction Open Exchange Rates provides a simple, lightweight and portable JSON API with live and historical foreign exchange (forex) rates, via a simple and easy-to-integrate API, in JSON format. Data are tracked and blended algorithmically from multiple reliable sources, ensuring fair and unbiased consistency. Exchange rates published through the Open Exchange Rates API are collected from multiple reliable providers, blended together and served up in JSON format for everybody to use. There are no complex queries, confusing authentication methods or long-term contracts. End-of-day rates are available historically for all days going back to 1st January, 1999. ``` -------------------------------- ### GET /api/latest.json with Symbols Source: https://docs.openexchangerates.org/reference/get-specific-currencies Retrieve the latest exchange rates for a specific subset of currencies by using the 'symbols' query parameter. This is recommended to minimize response size and improve performance. ```APIDOC ## GET /api/latest.json?symbols=GBP,EUR,AED,CAD ### Description Retrieves the latest exchange rates for a specified list of currencies. The `symbols` parameter accepts a comma-separated list of standard 3-letter ISO currency codes. ### Method GET ### Endpoint /api/latest.json ### Parameters #### Query Parameters - **app_id** (string) - Required - Your unique application ID. - **symbols** (string) - Optional - A comma-separated list of 3-letter ISO currency codes (e.g., 'GBP,EUR,AED,CAD'). ### Request Example ```http https://openexchangerates.org/api/latest.json?app_id=[[app:app_id]]&symbols=GBP,EUR,AED,CAD ``` ### Response #### Success Response (200) - **disclaimer** (string) - Information regarding the terms of use. - **license** (string) - Information regarding the license. - **timestamp** (integer) - The time at which the rates were generated. - **base** (string) - The base currency against which rates are provided. - **rates** (object) - An object containing currency codes as keys and their corresponding exchange rates as values. #### Response Example ```json { "disclaimer": "https://openexchangerates.org/terms/", "license": "https://openexchangerates.org/license/", "timestamp": 1424127600, "base": "USD", "rates": { "AED": 3.67295, "CAD": 0.99075, "EUR": 0.793903, "GBP": 0.62885 } } ``` ``` -------------------------------- ### Get API Usage Data (HTTP) Source: https://docs.openexchangerates.org/reference/usage-json This snippet shows how to retrieve your API usage statistics, including request counts and quotas, using an HTTP GET request. Requires a valid application ID. ```http https://openexchangerates.org/api/usage.json?app_id=YOUR_APP_ID ``` -------------------------------- ### List Supported Currencies Source: https://docs.openexchangerates.org/reference/supported-currencies Fetches a list of all currencies supported by the Open Exchange Rates API. This endpoint provides the most up-to-date information on available currency data. ```APIDOC ## GET /currencies.json ### Description Retrieves a JSON object containing all supported currency codes and their respective names. ### Method GET ### Endpoint /currencies.json ### Parameters #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **currency_code** (string) - The ISO 4217 currency code (e.g., "USD"). - **currency_name** (string) - The full name of the currency (e.g., "United States Dollar"). #### Response Example ```json { "USD": "United States Dollar", "EUR": "Euro", "JPY": "Japanese Yen" } ``` ``` -------------------------------- ### Include Alternative Currencies (HTTP Request) Source: https://docs.openexchangerates.org/reference/currencies-json Demonstrates how to request a list of currencies that includes unofficial, black market, and alternative digital currencies. This is achieved by appending the `show_alternative=1` query parameter to the base URL. This example shows the raw HTTP request structure. ```http https://openexchangerates.org/api/currencies.json ?show_alternative=1 ``` -------------------------------- ### Get API Usage Data (JavaScript with jQuery) Source: https://docs.openexchangerates.org/reference/usage-json Demonstrates how to fetch API usage data using JavaScript with the jQuery library. This method makes a GET request to the usage endpoint and logs the response to the console. Ensure jQuery is included in your project. ```javascript $.get('https://openexchangerates.org/api/usage.json', {app_id: 'YOUR_APP_ID'}, function(data) { console.log(data); }); ``` -------------------------------- ### Request Bid-Ask Rates with show_bid_ask Source: https://docs.openexchangerates.org/reference/bid-ask-prices Demonstrates how to append the `show_bid_ask=1` query parameter to an API request to fetch bid, ask, and mid prices. This is used with endpoints like `latest.json`, `historical/`, or `spot.json`. ```http https://openexchangerates.org/api/latest.json ?app_id=YOUR_APP_ID &show_bid_ask=1 ``` -------------------------------- ### Request Specific Currencies (JavaScript jQuery) Source: https://docs.openexchangerates.org/reference/get-specific-currencies This JavaScript code snippet uses the jQuery library to make a GET request to the Open Exchange Rates API, specifying a comma-separated list of currency symbols to retrieve. The response is logged to the console. ```javascript $.get('https://openexchangerates.org/api/latest.json', {app_id: '[[app:app_id]]', symbols: 'GBP,EUR,AED,CAD'}, function(data) { console.log(data); }); ``` ```javascript $.get('https://openexchangerates.org/api/latest.json', {app_id: '[[app:app_id]]', symbols: 'QAR,RUB,SEK'}, function(data) { console.log("1 US Dollar equals " + data.rates.SEK + " Swedish Krona"); }); ``` -------------------------------- ### Show Alternative Currencies Source: https://docs.openexchangerates.org/reference/supported-currencies To include alternative, black market, and digital currencies in your exchange rate requests, append the `show_alternative=true` query parameter to your API calls. Refer to the [alternative currencies documentation](https://docs.openexchangerates.org/docs/alternative-currencies) for more details. ```APIDOC ## GET /api/latest ### Description Fetches the latest exchange rates, optionally including alternative, black market, and digital currencies. ### Method GET ### Endpoint /api/latest ### Parameters #### Query Parameters - **show_alternative** (boolean) - Optional - Set to `true` to include alternative, black market, and digital currencies in the response. ### Request Example ``` GET /api/latest?app_id=YOUR_APP_ID&base=USD&symbols=EUR,BTS,DOGE,VEF_BLKMKT&show_alternative=true ``` ### Response #### Success Response (200) - **rates** (object) - An object containing the exchange rates for the requested currencies. - **date** (string) - The date of the exchange rates. - **timestamp** (integer) - The Unix timestamp of the exchange rates. #### Response Example ```json { "rates": { "EUR": 0.921234, "BTS": 150.5678, "DOGE": 0.123456, "VEF_BLKMKT": 100000.000000 }, "date": "2025-01-01", "timestamp": 1735689600 } ``` ``` -------------------------------- ### Get Usage Statistics with jQuery Source: https://docs.openexchangerates.org/reference/usage-json This snippet demonstrates how to fetch usage statistics for an Open Exchange Rates App ID using jQuery's AJAX functionality. It makes a GET request to the usage.json endpoint and logs the number of requests made this month to the console. ```javascript $.get('https://openexchangerates.org/api/usage.json', {app_id: 'YOUR_APP_ID'}, function(response) { console.log("This Open Exchange Rates app ID has made " + response.data.usage.requests + " hits this month."); }); ``` -------------------------------- ### Fetch Currencies with Alternative/Experimental Rates (jQuery) Source: https://docs.openexchangerates.org/reference/currencies-json Retrieves a JSON list of currencies, including alternative or experimental ones, using jQuery. The `show_experimental=1` parameter is appended to the URL to include these additional currencies. The console logs the entire response object. ```javascript $.get('https://openexchangerates.org/api/currencies.json?show_experimental=1', function(data) { console.log(data); }); ``` -------------------------------- ### POST /convert Source: https://docs.openexchangerates.org/reference/convert Converts a specified amount from one currency to another using the latest available exchange rates. This endpoint is part of the Unlimited plan features and provides detailed meta-information about the conversion. ```APIDOC ## POST /convert ### Description Converts a specified amount from one currency to another using the latest available exchange rates. This endpoint is part of the Unlimited plan features and provides detailed meta-information about the conversion. ### Method POST ### Endpoint /convert ### Parameters #### Query Parameters - **apikey** (string) - Required - Your API key. - **from** (string) - Required - The currency code to convert from (e.g., "USD"). - **to** (string) - Required - The currency code to convert to (e.g., "EUR"). - **amount** (number) - Required - The amount of currency to convert. ### Request Example ```json { "example": "POST /convert?apikey=YOUR_API_KEY&from=USD&to=EUR&amount=100" } ``` ### Response #### Success Response (200) - **response** (number) - The converted currency value. - **rate** (number) - The exchange rate used for the conversion. - **timestamp** (integer) - The Unix timestamp of the rate used. - **request** (object) - An object containing the parameters used in the request for validation. - **amount** (number) - The original amount. - **from** (string) - The source currency. - **to** (string) - The target currency. #### Response Example ```json { "example": { "response": 92.50, "rate": 0.925, "timestamp": 1678886400, "request": { "amount": 100, "from": "USD", "to": "EUR" } } } ``` ```