XE Currency Data API v1.0 Specifications 2018 Mar 20
XE Currency Data API v1.0 Specifications 2018 Mar 20
0
Specifications
2018 Mar 20
1 Overview ............................................................................................................ 3
1.1 Schema ............................................................................................................................................................3
1.2 Caching Data .................................................................................................................................................3
1.3 Authentication .............................................................................................................................................3
1.4 Specifying the API Version......................................................................................................................4
1.5 Specifying the Data Format ....................................................................................................................4
1.6 Timestamp (Date and Time) Format .................................................................................................5
1.7 Package Limits .............................................................................................................................................5
1.8 Usage Restriction ........................................................................................................................................6
1.9 Conditional requests .................................................................................................................................7
2 API Endpoints ..................................................................................................... 8
2.1 Account information .................................................................................................................................8
2.2 Currencies ......................................................................................................................................................9
2.3 Convert From Exchange Rates ........................................................................................................... 10
2.4 Convert To Exchange Rates ................................................................................................................. 11
2.5 Historic Rate .............................................................................................................................................. 13
2.6 Historic Rate period................................................................................................................................ 14
2.7 Monthly Average ...................................................................................................................................... 17
2.8 Stats ............................................................................................................................................................... 18
3 Appendix 1 – API Alerts..................................................................................... 21
The XE Currency Data API is a REST-ful (or REST-like, depending how strictly you
interpret REST) web-services API.
1.1 Schema
• The API is accessed using the HTTPS protocol.
• The API is accessed from the domain xecdapi.xe.com.
• All data is sent and received in the JSON format by default. You can optionally
specify XML or CSV formats instead.
1.3 Authentication
All requests to the API must be authenticated via HTTP Basic Access Authentication,
which requires that a properly constructed “Authorization” header be included in your
HTTP request. This header will need to include your XE Currency Data API account ID
and API key in an encoded form. Your account ID and API key will be provided to you
when you sign up for the service. You can get more information on Basic Access
Authentication at: http://en.wikipedia.org/wiki/Basic_access_authentication
Most modern programming languages and tools support this authentication method
natively and take care of the details for you.
{
"code":1,
"message": "Bad credentials",
"documentation_url": "https://xecdapi.xe.com/docs/v1/"
}
{
"code":2,
"message": "Maximum number of login attempts exceeded. Please try again later.",
"documentation_url": "https://xecdapi.xe.com/docs/v1/"
}
https://xecdapi.xe.com/v{version_no}/...
Where {version_no} is an integer that identifies the version number that you wish to
access.
Example:
https://xecdapi.xe.com/v1/account_info/
https://xecdapi.xe.com/v1/{endpoint}{.format}/...
Where {endpoint} is the specific API endpoint (data) you are requesting and
{.format} indicates the format in which you would like the data to be returned.
YYYY-MM-DDThh:mm:ssZ
If you have a Daily package and you have specified a preferred Lock-In time and Time
Zone in your agreement then the API will return data based on these settings in UTC
time.
Small package level: provides you with 10,000 API rate requests a month.
Medium package level: provides you with 100,000 API rate requests a month.
Enterprise package level: provides you with Unlimited API rate requests a month.
Each rate returned is considered one API request towards your monthly package limit.
You can request multiple rates in a single query
For example: Convert $1,500 From USD to CAD and GBP will count as two rate requests
towards your monthly package limit as it contains two counter currencies (CAD and
GBP).
When you have used your monthly package allowance, your access will be blocked until
your new monthly access period begins.
You can check your current package limit status by using the account_info API
endpoint without impacting your API request count. See section 2.1.
Once you hit your package limit you will receive an error response:
HTTP/1.1 403 Forbidden
Status: 403 Forbidden
X-RateLimit-Limit: 900
X-RateLimit-Remaining: 851
{
"code":3,
"message": "API package limit reached.",
"documentation_url": "https://xecdapi.xe.com/docs/v1/"
}
You can check the returned HTTP headers of any API request to see your current usage
restriction status:
curl –i -u account_id:api_key -i
"https://xecdapi.xe.com/v1/convert_to.json/?to=USD&from=CAD&amount=1000.00"
HTTP/1.1 200 OK
Status: 200 OK
X-RateLimit-Limit: 900
X-RateLimit-Remaining: 851
X-RateLimit-Reset: 1372700873
X-RateLimit-Limit The maximum number of requests that you are permitted to make per usage
restriction window.
X-RateLimit- The number of requests remaining in the current usage restriction window.
Remaining
X-RateLimit-Reset The time at which the current usage restriction window resets in UTC epoch
seconds.
If you need the time in a different format, any modern programming language can get
the job done. For example, if you open up the console on your web browser, you can
easily get the reset time as a JavaScript Date object.
new Date(1372700873 * 1000) // => Mon Jul 01 2013 13:47:53 GMT-0400 (EDT)
Once you go over the rate limit you will receive an error response:
HTTP/1.1 429 Too Many Requests
Status: 429 Too Many Requests
X-RateLimit-Limit: 900
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1377013266
{
"code":4,
"message": "API request rate limit exceeded.",
"documentation_url": "https://xecdapi.xe.com/docs/v1/"
}
Most responses return an ETag header. Many responses also return a Last-
Modified header. You can use the values of these headers to make subsequent
requests to those resources using the If-None-Match and If-Modified-Since headers,
respectively. If the resource has not changed, the server will return a
304 Not Modified .
Note: Making a conditional request and receiving a 304 response does not count against
your API request count so we encourage you to use it whenever possible.
2 API Endpoints
This section outlines the different endpoints that are available. You can think of an
endpoint as a function or a resource that allows you to request information about a
particular type of data.
GET /v1/account_info{.format}
2.1.2 Response
Status: 200 OK
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4456
X-RateLimit-Reset: 1350085394
{
"id": "E1EABC7B-A9C6-97EB-C5C9-E14E501A06E9",
"organization": "Acme Inc.",
"package": "enterprise",
"service_start_timestamp": "2013-01-23T13:27Z",
"package_limit_duration": "1 month"
"package_limit": 10000,
"package_limit_remaining": 8347,
"package-limit_reset": "2014-11-23T00:00Z"
}
GET /v1/currencies{.type}/?{obsolete=true}{&language=en}{&iso=XXX…}
If the obsolete optional parameter is included, then the list will contain both active and
obsolete currencies.
Example:
curl –i -u account_id:api_key
"https://xecdapi.xe.com/v1/currencies.json/?obsolete=true"
2.2.1 Response
Status: 200 OK
X-RateLimit-Limit: 900
X-RateLimit-Remaining: 851
X-RateLimit-Reset: 1350085394
ETag: "a0s049ba79152f03380d34652f2cb612"
{
"terms":"http://www.xe.com/legal/dfs.php",
"privacy":"http://www.xe.com/privacy.php",
"currencies": [
{
"iso": "CAD",
"currency_name": "Canadian Dollar",
"is_obsolete": false
},
{
"iso": "FRF",
"currency_name": "France Francs",
"is_obsolete": true,
"superseded_by": "EUR"
}
. . .
]
}
2.2.2 Parameter
language String OPTIONAL – parameter used to specify the language in which you would like the
currency names to be provided. Specified as an RFC-1766-compliant language tag.
Currently supported languages include "ar", "de", "en", "es", "fr", "it", "ja", "pt",
"sv", "zh-CN", and "zh-HK". If not specified, “en” is used.
iso String OPTIONAL – Comma separated list of ISO 4217 codes. This will limit the data
returned to only those currencies that are specified. If this parameter is omitted, this
It is a prefix match; you can provide it with one, two, or three characters and it will
return a list of all the currencies with ISO 4217 codes that match.
For example, if you have $110.23 USD, how much CAD will that get you.
Note:
Daily – will return last rate at your preferred lock-in time.
Live – will return latest exchange rate.
GET /v1/convert_from{.format}/?{from=XXX}{&to=XXX…}{&amount=n}
Example:
curl –i -u account_id:api_key
"https://xecdapi.xe.com/v1/convert_from.json/?from=USD&to=CAD,EUR
&amount=110.23"
2.3.1 Response
Status: 200 OK
X-RateLimit-Limit: 900
X-RateLimit-Remaining: 851
X-RateLimit-Reset: 1350085394
ETag: “a0s049ba79152f03380d34652f2cb612”
{
"terms":"http://www.xe.com/legal/dfs.php",
"privacy":"http://www.xe.com/privacy.php",
"from": "USD",
"amount":110.23,
"timestamp": "2014-04-23T14:20:00Z",
"to": [
{
"quotecurrency": "CAD",
"mid": 121.7363552834
},
{
"quotecurrency": "EUR",
2.3.2 Parameters
to String Comma separated list of to currencies ISO 4217 codes. This will limit the
data returned to only those currencies that are specified. Use an asterisk *
to convert all currencies. Note: Obsolete currencies are replaced by their
successor currency.
amount Number OPTIONAL – This parameter can be used to specify the amount you want
to convert, if an amount is not specified then 1 is assumed.
obsolete String OPTIONAL – If ‘true’ then endpoint will display rates for currencies that
are obsolete. If ‘false’ then obsolete currencies are replaced by their
successor currency.
inverse String If ‘true’ then endpoint will include inverse rates. An inverse rate is a quote
for which the base currency and counter currency are switched. An
inverse is calculated by dividing one by the exchange rate.
Example: If the exchange rate for $1 USD to EUR = 0.874852, then the
inverse rate would be 1/0.874852 = 1.14305, meaning that US$1.14305
would buy 1 euro.
decimal_places Number OPTIONAL – This parameter can be used to specify the number of decimal
places included in the output. Example 1 USD to EUR = 0.874852 with
decimal_places=3, the output returned will be EUR = 0.875
margin Number OPTIONAL – This parameter can be used to add a margin (-/+) to XE's mid-
market rate. Example: add margin=2.05 parameter to the endpoint and
the API will return our mid-market rates plus the margin of 2.05 percent.
For example, how much USD and EUR do you need to get $1000 CAD.
Note:
Daily – will return last rate at your preferred lock-in time.
Live – will return latest exchange rate.
GET /v1/convert_to{.format}/?{to=XXX}{&from=XXX…}{&amount=n}
Example:
curl –i -u account_id:api_key
"https://xecdapi.xe.com/v1/convert_to.json/?to=CAD&from=USD,EUR&amount=1000.00"
2.4.1 Response
Status: 200 OK
X-RateLimit-Limit: 900
X-RateLimit-Remaining: 851
X-RateLimit-Reset: 1350085394
ETag: “a0s049ba79152f03380d34652f2cb612”
{
"terms":"http://www.xe.com/legal/dfs.php",
"privacy":"http://www.xe.com/privacy.php",
"to": "CAD",
"amount":1000.00,
"timestamp": "2014-04-23T14:24:00Z",
"from": [
{
"quotecurrency": "USD",
"mid": 905.4803114341
},
{
"quotecurrency": "EUR",
"mid": 656.7101615851
}
]
}
2.4.2 Parameters
to String OPTIONAL - Currency you want to convert to ISO code. Note if this
parameter is omitted, USD is assumed.
amount Number OPTIONAL – This parameter can be used to specify the amount you want
to convert, if an amount is not specified then 1 is assumed.
obsolete String OPTIONAL – If ‘true’ then endpoint will display rates for currencies that
are obsolete. If ‘false’ then obsolete currencies are replaced by their
successor currency.
inverse String OPTIONAL – If ‘true’ then endpoint will include inverse rates.
margin Number OPTIONAL – This parameter can be used to add a margin (-/+) to XE's mid-
market rate. Example: add margin=2.05 parameter to the endpoint and
the API will return our mid-market rates plus the margin of 2.05 percent.
GET /v1/historic_rate.{format}/{?from=XXX}{&to=XXX…}{&date=yyyy-mm
dd}{&time=hh:mm}(&amount=n}
Example:
curl –i -u account_id:api_key
"https://xecdapi.xe.com/v1/historic_rate.json/?from=USD&date=2011-03-05&to=CAD,JPY"
2.5.1 Response
Status: 200 OK
X-RateLimit-Limit: 900
X-RateLimit-Remaining: 861
X-RateLimit-Reset: 1350085394
{
"terms":"http://www.xe.com/legal/dfs.php",
"privacy":"http://www.xe.com/privacy.php",
"from": "USD",
"amount":1.0,
"timestamp": "2011-03-05T17:00:00Z",
"to": [
{
"quotecurrency":"CAD",
"mid":0.9727929102
},
{
"quotecurrency":"JPY",
"mid":82.3000430273
}]
}
2.5.2 Parameters
If your account is registered for a Daily package your endpoint will return
rates at your preferred daily lock-in time.
If your account is registered for a Live package your endpoint will return
XE mid-day rate unless you specify a time parameter in your rate request.
time String OPTIONAL – Time parameter is applicable to Live package only – UTC time
is in format of HH:MM
Time option is only available for the last 24 hours, if time is not specified,
only one table is returned using the XE mid-day rates (As returned in
http://www.xe.com/currencytables/)
amount Number OPTIONAL – This parameter can be used to specify the amount you want
to convert, if an amount is not specified then 1 is assumed.
obsolete String OPTIONAL – If ‘true’ then endpoint will display rates for currencies that
are obsolete. If ‘false’ then obsolete currencies are replaced by their
successor currency.
inverse String OPTIONAL – If ‘true’ then endpoint will include inverse rates.
decimal_places Number OPTIONAL – This parameter can be used to specify the number of decimal
places included in the output. Example 1 USD to EUR = 0.874852 with
decimal_places=3, the output returned will be EUR = 0.875
margin Number OPTIONAL – This parameter can be used to add a margin (-/+) to XE's
mid-market rate. Example: add margin=2.05 parameter to the endpoint
and the API will return our mid-market rates plus the margin of 2.05
percent.
GET
/v1/historic_rate/period{.type}/{?from=XXX}{&to=XXX…}{&start_timestamp=YYYY-
MM-DD}{&end_timestamp=YYYY-MM-DD}{&amount=n}
Example:
2.6.1 Response
Status: 200 OK
X-RateLimit-Limit: 900
X-RateLimit-Remaining: 851
X-RateLimit-Reset: 1350085394
ETag: “a0s049ba79152f03380d34652f2cb612”
{
"terms":"http://www.xe.com/legal/dfs.php",
"privacy":"http://www.xe.com/privacy.php",
"from": "USD",
"amount":1.0,
"to": [
"CAD": [
{
"mid":0.9933549894,
"timestamp":"2013-01-01T17:00:00Z
},
{
"mid":0.9860217910,
"timestamp":"2013-01-02T17:00:00Z
}]
]
}
2.6.2 Parameters
to String Comma separated list of to currencies based on ISO 4217 codes. This
will limit the data returned to only those currencies that are specified.
amount Number OPTIONAL – This parameter can be used to specify the amount you
want to convert, if an amount is not specified then 1 is assumed.
interval String OPTIONAL – Interval is applicable to Live packages only. Using one of
the interval values below in your rate request will return rates for that
specific interval within the time period specified.
Example: adding the interval of “hourly” will return rates for every
hour in the time period you specified.
“daily” Returns one rate for the days specified in your time
period.
“hourly” Returns rates for every hour in the time period you
specify.
page Number OPTIONAL – You can specify the page number you want to request.
Note that page numbering is 1-based (the first page being page 1).
Omitting this parameter will return the first page.
per_page Number OPTIONAL – You can specify the number of results per page. The
default is 30 results per page with a maximum of 100 results per page.
obsolete String OPTIONAL – If ‘true’ then endpoint will display rates for currencies
that are obsolete. If ‘false’ then obsolete currencies are replaced
by their successor currency.
inverse String OPTIONAL – If ‘true’ then endpoint will include inverse rates.
decimal_places Number OPTIONAL – This parameter can be used to specify the number of
decimal places included in the output. Example 1 USD to EUR =
0.874852 with decimal_places=3, the output returned will be EUR
= 0.875
margin Number OPTIONAL – This parameter can be used to add a margin (-/+) to
XE's mid-market rate. Example: add margin=2.05 parameter to the
GET
/v1/monthly_average{.type}/{?from=XXX}{&to=XXX…}{&year=YYYY}{&month=M}{&amount
=n}
Example:
curl –i -u account_id:api_key "https://xecdapi.xe.com/v1/
monthly_average/?from=USD&to=EUR&year=2015&month=6"
2.7.1 Response
Status: 200 OK
X-RateLimit-Limit: 900
X-RateLimit-Remaining: 899
X-RateLimit-Reset: 1472579220
ETag: “a0s049ba79152f03380d34652f2cb612”
{
"terms":"http://www.xe.com/legal/dfs.php",
"privacy":"http://www.xe.com/privacy.php",
"from": "USD",
"amount":1,
"year":2015,
"to": {
"CAD": [
{
"monthlyAverage":1.2354042806,
"month":6,
"daysInMonth":30
}]
}
}
2.7.2 Parameters
to String Comma separated list of to currencies based on ISO 4217 codes. This
amount Number OPTIONAL – This parameter can be used to specify the amount you
want to convert, if an amount is not specified then 1 is assumed.
year String OPTIONAL – This parameter specifies the year to calculate average
monthly rates.
month String OPTIONAL – This parameter specifies the month in the given year to
return average monthly rates. This is a numeric value from 1 to 12
where 1 is for January and 12 is for December. If no month is
provided, then all months for the given year are returned.
obsolete String OPTIONAL – If ‘true’ then endpoint will display rates for currencies
that are obsolete. If ‘false’ then obsolete currencies are replaced by
their successor currency.
inverse String OPTIONAL – If ‘true’ then endpoint will include inverse rates.
decimal_places Number OPTIONAL – This parameter can be used to specify the number of
decimal places included in the output. Example 1 USD to EUR =
0.874852 with decimal_places=3, the output returned will be EUR =
0.875
2.8 Stats
Volatility measures the fluctuation in the exchange rate of a currency pair over a specific
period, represented in a percentage. At XE, volatility is measured by applying the
standard deviation of the logarithmic daily returns, expressed in a percentage score.
Daily returns are the gain or loss of a currency pair in a particular period. We take the
values of two consecutive days at 00:00 UTC. That is why we call it daily return. Then,
we apply a logarithm to the ratio between those two values. It is a common way to
measure change in the financial industry.
Ex: ln (valueDay2 / valueDay1) is the logarithmic return between day2 and day1. We
have a value that tells us if the currency pair has moved a lot or not.
In statistics, the standard deviation is a measure that is used to quantify the amount of
variation of a set of data values. A low standard deviation indicates that the data points
tend to be close to the mean of the set, while a high standard deviation indicates that
the data points are spread out over a wider range of value.
GET /v1/stats{.format}/{?from=XXX}{&to=XXX…}{&start_date=yyyy-mm
dd}{&end_date=yyyy-mm dd}{&daysInPeriod=n}
Example:
curl –i -u account_id:api_key "https://xecdapi.xe.com/v1/
stats?from=USD&to=EUR&start_date=2016-01-01&end_date=2017-01-01"
2.8.1 Response
Status: 200 OK
X-RateLimit-Limit: 900
X-RateLimit-Remaining: 899
X-RateLimit-Reset: 1472579220
ETag: “a0s049ba79152f03380d34652f2cb612”
{
"terms":"http://www.xe.com/legal/dfs.php",
"privacy":"http://www.xe.com/privacy.php",
"startDate":"2016-01-01T00:00:00Z",
"endDate":"2017-01-01T00:00:00Z",
"from": "USD",
"stats": [
{
"to": "EUR",
"high": "0.96241958842401",
"low": "0.86778524440646",
"average": "0.9040496695395371",
"standardDeviation": "0.02093481087412211",
"volatility": "0.4383874561564132",
"highTimestamp": "2016-12-21T00:00:00Z",
"lowTimestamp": "2016-15-03T00:00:00Z",
"dataPoints": "367"
}]
}
2.8.2 Parameters
to String Comma separated list of to currencies based on ISO 4217 codes. This
will limit the data returned to only those currencies that are specified.
start_date String OPTIONAL – ISO 8601 timestamp in the format yyyy-mm-dd giving the
UTC date of the start of the period for which you would like to
end_date String OPTIONAL – ISO 8601 timestamp in the format yyyy-mm-dd giving the
UTC date of the end of the period for which you would like to
compute the volatility to. Note if this parameter is omitted, the end
date will default to today.
obsolete String OPTIONAL – If ‘true’ then endpoint will display rates for currencies
that are obsolete. If ‘false’ then obsolete currencies are replaced by
their successor currency.
decimal_places Number OPTIONAL -This parameter can be used to specify the number of
decimal places included in the output. Example 1 USD to EUR =
0.874852 with decimal_places=3, the output returned will be EUR =
0.875
This table outlines the various alerts that you could potentially encounter.