Exchange Rates Application Programming Interface (API)
Download the .json file (12.4 KB)Usage
This API allows users to query for active foreign exchange rates. The recorded rates indicate the number of Canadian dollars required to buy a single unit of the foreign currency. New rates are released by the Bank of Canada (BoC) daily at 4:30 pm. The Canada Border Services (CBSA) retrieves these updates between 4:30 pm and 5 pm ET.
BoC provides 23 foreign exchange rates. All other rates are maintained by the CBSA.
Exchange rates from the BoC are updated daily in the system while other exchange rates are updated by the CBSA at set intervals. The updated rates are available for retrieval between 7 pm and 11:59 pm ET.
If the above mentioned window is missed, the user can still fetch active foreign exchange rates by using the Historical Exchange Rate API.
Please note, when using the Historical Exchange Rate API:
- The StartDate and EndDate parameters are required.
- If fetching a large amount of data use the limit and skip parameters.
Update frequency
As BoC publishes exchange rates every business day, it is recommended that exchange rate data be retrieved on a daily basis. This retrieval should occur after 7 pm ET to ensure retrieval of the latest updates.
Technical notes
The Exchange Rate API uses LoopBack 4, an open source framework to create dynamic end-to-end REST API. Please refer to AWS API Gateway for further details. There will be two servers provided, one for development and testing and a second for actual production data. Please ensure these are accessed appropriately during the development lifecycle.
Error codes
Type: Data Validation
HTTP status code: 400 (Bad Request)
Description: The client sends some invalid data in the request, for example, missing or incorrect content in the payload or parameters. Could also represent a generic client error.
Type: Throttling
HTTP status code: 429 (Too Many Requests)
Description: The client is sending more than the allowed number of requests per unit time.
Type: Dependency Issues
HTTP status code: 502 (Bad Gateway)-504 (Gateway Timeout)
Description: A dependent service is throwing errors (502) or timing out (504).
Type: Unhandled Errors
HTTP status code: 500 (Internal Server Error)-503 (Service Unavailable)
Description: The service failed in an unexpected way (500), or is failing but is expected to recover (503).
Paths
GET https://bcd-api-dca-ipa.cbsa-asfc.cloud-nuage.canada.ca/exchange-rate-lambda/exchange-rates
(exchangeRateControllerExternal.find)
Finds all of the exchange rates that match the filter (If no filter is specified all rates are returned)
Query parameters
Return type
Example data
"ForeignExchangeRates": [
{
"ExchangeRateId": 719352,
"Rate": "0.1589",
"ExchangeRateEffectiveTimestamp": "2021-11-03T00:00:00.000Z",
"ExchangeRateExpiryTimestamp": "2021-11-03T23:59:59.000Z",
"ExchangeRateSource": "BoC",
"FromCurrency": {
"Value": "HKD"
},
"FromCurrencyCSN": 87,
"ToCurrency": {
"Value": "CAD"
},
"ToCurrencyCSN": 36
},
]
Produces
This API call produces the following media types according to the Accept request header; the media type will be conveyed by the Content-Type response header.application/json
Responses
200
Array of ExchangeRate model instancesModels
Table of Contents
ExchangeRate.Filter
- ExchangeRate.Filter Up
ExchangeRateWithRelations
- ExchangeRateWithRelations Up
Description: A unique identifier for all active and historical exchange rates
Description: A pointer to the source the exchange rate (Primarily Bank of Canada (BoC) and CBSA)
Description: A pointer to the three character currency description, which represents the currency of the 'Rate'
Description: A pointer to the three character currency code, which represents the currency of the 'Rate'
Description: A pointer to the three character currency description, which represents the currency of the 'Rate'
Description: A pointer to the three character currency code, which represents the currency of the output when dividing an amount of money (in the 'FromCurrency') by the 'Rate'
Description: The number of 'FromCurrency' units required to buy a single 'ToCurrency' unit
Description:The date when the exchange rate is active (inclusive bound)
Description: The date when the exchange rate is no longer active (exclusive bound)
GET https://bcd-api-dca-ipa.cbsa-asfc.cloud-nuage.canada.ca/exchange-rate-lambda/exchange-rates?startDate=2021-10-22&endDate=2021-10-23&limit=10&skip=2
(exchangeRateControllerExternal.find)
Finds all of the exchange rates that match the filter (If no filter is specified all rates are returned)
Query parameters
Description:The date when the exchange rate is active (inclusive bound)
Description: The date when the exchange rate is no longer active (exclusive bound)
Return type
Example data
"ForeignExchangeRates": [
{
"ExchangeRateId": 718988,
"Rate": "0",
"ExchangeRateEffectiveTimestamp": "2021-10-22T00:00:00.000Z",
"ExchangeRateExpiryTimestamp": "2021-10-22T23:59:59.000Z",
"ExchangeRateSource": "CBSA",
"FromCurrency": {
"Value": "bpg"
},
"FromCurrencyCSN": 267,
"ToCurrency": {
"Value": "CAD"
},
"ToCurrencyCSN": 36
},
{
"ExchangeRateId": 718990,
"Rate": "0",
"ExchangeRateEffectiveTimestamp": "2021-10-22T00:00:00.000Z",
"ExchangeRateExpiryTimestamp": "2021-10-22T23:59:59.000Z",
"ExchangeRateSource": "CBSA",
"FromCurrency": {
"Value": "mpg"
},
"FromCurrencyCSN": 266,
"ToCurrency": {
"Value": "CAD"
},
"ToCurrencyCSN": 36
},
]
Produces
This API call produces the following media types according to the Accept request header; the media type will be conveyed by the Content-Type response header.application/json
Responses
200
Array of ExchangeRate model instancesModels
Table of Contents
ExchangeRate.Filter
- ExchangeRate.Filter Up
Description: A query parameter to specify the maximum number of 100 items to return in a response
Description: A query parameter to exclude the first 2 items from a response body
Description: A query parameter to represent the end of the date range within which the rates are being requested
Description: A unique identifier for all active and historical exchange rates
Description: A pointer to the source the exchange rate (Primarily Bank of Canada (BoC) and CBSA)
Description: A pointer to the three character currency description, which represents the currency of the 'Rate'
Description: A pointer to the three character currency code, which represents the currency of the 'Rate'
Description: A pointer to the three character currency description, which represents the currency of the 'Rate'
Description: A pointer to the three character currency code, which represents the currency of the output when dividing an amount of money (in the 'FromCurrency') by the 'Rate'
Description: The number of 'FromCurrency' units required to buy a single 'ToCurrency' unit
Description:The date when the exchange rate is active (inclusive bound)
Description: The date when the exchange rate is no longer active (exclusive bound)
Page details
- Date modified: