Currencies API

Powered by 14+ third party exchange rate data sources, the Currencies.dev API is capable of delivering currency conversions of all 135+ Stripe currencies. The API comes with multiple endpoints, each serving a different use case. Endpoint functionalities include converting to and from smallest units - used for the "amount" value on Stripe price objects, converting amounts from one currency to another.

Throughout this documentation you will learn about API structure, methods, potential errors and code examples. In case there any question is left unanswered, please make sure to contact us and our team will be happy to help out.

Getting Started

Definitions

DEFINITIONS SUMMARY
API Key
A unique key assigned to each API account used to authenticate with the API.
Symbol
Refers to the three-letter currency code of a given currency.
Base Currency
The currency to which exchange rates are relative to. (If 1 USD = X EUR, USD is the base currency)
Target Currency
The currency an amount is converted to. (If 1 USD = X EUR, EUR is the target currency)
Base URL
Refers to URL which all API request endpoints and URLs are based on.

API Key

Your API Key is the unique key that is passed into the API base URL's api_key parameter in order to authenticate with the Currencies API.

Base URL:

BASE URL
https://api.currencies.dev

Append your API Key: Here is how to authenticate with the Currencies API:

APPEND YOUR API KEY

https://api.currencies.dev/supported_currencies

?api_key=API_KEY

Response

All data is returned in standard JSON format and can be parsed easily using any programming language.

Example Response: Below you will find an example API response carrying the latest 135+ native currencies supported by Stripe. This particular API request is not rate limited and infact does not even require an API key.

SUPPORTED CURRENCIES RESPONSE

{

"success": true,

"timestamp": 1718892703869,

"date": "2024-06-20",

"currencies": [

"USD",

"AED",

"AFN",

"ALL",

"AMD",

"ANG",

"AOA",

[ . . . ]

}

}

The API's response will always contain a success object returning whether the request was successful or not.

Available Endpoints

The Currencies API comes with 4 endpoints, each providing a different functionality.

SSL Connection

All Currencies.dev subscription plans come with 256-bit SSL encryption. To connect to the API via SSL, simply use the https protocol instead of standard http.

Potential Errors

Whenever a requested resource is not available or an API call fails for another reason, a JSON error is returned. Errors always come with an error code and a description.

Example Error: The following error is returned if your 60 second rate limit API request volume has been exceeded.

EXAMPLE RATE LIMIT ERROR RESPONSE

{

"success": false,

"error": {

"code": 429,

"type": "rate_limit",

"info": "You have already made 10 requests in the past 60 seconds."

}

}

Other Errors:

ERROR CODE SUMMARY
400
Bad Request. Wrong input parameters.
401
No API Key was specified or an invalid API Key was specified.
403
The current subscription plan does not support this API endpoint.
404
The requested API endpoint does not exist.
422
An invalid base currency has been entered.
429
The maximum allowed API amount of 60 second API requests has been reached.
500
Internal server error.

Endpoints

Supported Currencies Endpoint

The Currencies API comes with a constantly updated endpoint returning all available currencies, which matches Stripe's available currencies. To access this list, make a request to the API'ssupported_currencies endpoint.

API Request:

SUPPORTED CURRENCIES REQUEST

https://api.currencies.dev/supported_currencies

?api_key=API_KEY

Request Parameters:

SUPPORTED CURRENCIES REQUEST PARAMATERS
api_key
[Optional] Your API Key.

API Response:

SUPPORTED CURRENCIES RESPONSE

{

"success": true,

"timestamp": 1718892703869,

"date": "2024-06-20",

"currencies": [

"USD",

"AED",

"AFN",

"ALL",

"AMD",

"ANG",

"AOA",

[ . . . ]

}

}

Response Objects:

SUPPORTED CURRENCIES RESPONSE OBJECTS
success
Returns true or false depending on whether or not your API request has succeeded.
timestamp
Returns the exact date and time (UNIX time stamp) the request was completed.
currencies
Returns all supported currencies with their respective three-letter currency codes.

Supported Currencies Endpoint:

JavaScript Fetch

const url = 'https://api.currencies.dev/supported_currencies?api_key={YOUR_API_KEY}';

const options = {

method: 'GET'

}


try {

const response = await fetch(url, options);

const result = await response.text();

console.log(result);

} catch (error) {

console.error(error);

}

Convert To Smallest Unit Endpoint

In Stripe, the "amount" value on price objects represents the unit amount to be charged in the smallest currency unit. Most currencies multiply by 100 (e.g., $10.00 is 1000 cents), while some, like the Japanese yen, do not (e.g., ¥1000 is 1000). Currency unit definitions can change frequently and unpredictably, making it challenging to keep up. Fortunately, you can make API requests to ourconvert_to_smallest_unit endpoint to convert prices to the up-to-date Stripe amount.

API Request:

CONVERT TO SMALLEST UNIT REQUEST

https://api.currencies.dev/convert_to_smallest_unit

?api_key=API_KEY

&currency=USD

&amount=5.50

Request Parameters:

CONVERT TO SMALLEST UNIT REQUEST PARAMATERS
api_key
[Required] Your API Key.
currency
[Required] The currency you are using. (e.g. USD)
amount
[Required] The amount you wish to convert. (e.g. $5.50 would be: &amount=5.50)

API Response:

CONVERT TO SMALLEST UNIT RESPONSE

{

"success": true,

"query": {

"amount": 5.5,

"currency": "usd"

},

"info": {

"timestamp": 1719244781602,

"decimals": 2

},

"date": "2024-06-24",

"result": 550

}

Response Objects:

CONVERT TO SMALLEST UNIT RESPONSE OBJECTS
success
Returns true or false depending on whether or not your API request has succeeded.
query > amount
Returns the input amount.
query > currency
Returns the three-letter currency code of the currency input.
info > timestamp
Returns the exact date and time (UNIX time stamp) the request was completed.
info > decimals
Returns the number of decimals which the queried amount was multiplied by.
result
Returns your conversion result.

Convert To Smallest Unit Endpoint:

JavaScript Fetch

const url = 'https://api.currencies.dev/convert_to_smallest_unit?currency=USD&amount=5.50&api_key={YOUR_API_KEY}';

const options = {

method: 'GET'

}


try {

const response = await fetch(url, options);

const result = await response.text();

console.log(result);

} catch (error) {

console.error(error);

}

Convert From Smallest Unit Endpoint

In Stripe, the "amount" value on price objects represents the unit amount to be charged in the smallest currency unit. To get the price in a way we are used to seeing, for most currencies we divide by 100 (e.g. for USD, 1000 is $10.00), while some, like the Japanese yen, do not (e.g., 1000 is ¥1000). Currency unit definitions can change frequently and unpredictably, making it challenging to keep up. Fortunately, you can make API requests to ourconvert_from_smallest_unit endpoint to convert amounts from stripe objects to the way our users are used to seeing them.

API Request:

CONVERT FROM SMALLEST UNIT REQUEST

https://api.currencies.dev/convert_from_smallest_unit

?api_key=API_KEY

&currency=USD

&amount=550

Request Parameters:

CONVERT FROM SMALLEST UNIT REQUEST PARAMATERS
api_key
[Required] Your API Key.
currency
[Required] The currency you are using. (e.g. USD)
amount
[Required] The Stripe price object amount you wish to convert.

API Response:

CONVERT FROM SMALLEST UNIT RESPONSE

{

"success": true,

"query": {

"amount": 550,

"currency": "usd"

},

"info": {

"timestamp": 1719244781602,

"decimals": 2

},

"date": "2024-06-24",

"result": 5.5

}

Response Objects:

CONVERT TO SMALLEST UNIT RESPONSE OBJECTS
success
Returns true or false depending on whether or not your API request has succeeded.
query > amount
Returns the input amount.
query > currency
Returns the three-letter currency code of the currency input.
info > timestamp
Returns the exact date and time (UNIX time stamp) the request was completed.
info > decimals
Returns the number of decimals which the queried amount was divided by.
result
Returns your conversion result.

Convert From Smallest Unit Endpoint:

JavaScript Fetch

const url = 'https://api.currencies.dev/convert_from_smallest_unit?currency=USD&amount=550&api_key={YOUR_API_KEY}';

const options = {

method: 'GET'

}


try {

const response = await fetch(url, options);

const result = await response.text();

console.log(result);

} catch (error) {

console.error(error);

}

Convert Currency Endpoint

The Currencies.dev API comes with a separate currency conversion endpoint, which can be used to convert any amount from one currency to another. In order to convert currencies, please use the API'sconvert_currency endpoint, append the from and to parameters and set them to your preferred base and target currency codes.

API Request:

CONVERT CURRENCY REQUEST

https://api.currencies.dev/convert_currency

?api_key=API_KEY

&from=GBP

&to=JPY

&amount=25

Request Parameters:

CONVERT CURRENCY REQUEST PARAMATERS
api_key
[Required] Your API Key.
from
[Required] The three-letter currency code of the currency you would like to convert from.
to
[Required] The three-letter currency code of the currency you would like to convert to.
amount
[Required] The amount to be converted.

API Response:

CONVERT CURRENCY RESPONSE

{

"success": true,

"query": {

"from": "gbp",

"to": "jpy",

"amount": 25

},

"info": {

"timestamp": 1719244781602,

"rate": 199.2668

},

"date": "2024-06-24",

"result": 4981.67

}

Response Objects:

CONVERT CURRENCY RESPONSE OBJECTS
success
Returns true or false depending on whether or not your API request has succeeded.
query > from
Returns the three-letter currency code of the currency converted from.
query > to
Returns the three-letter currency code of the currency converted to.
query > amount
Returns the amount that is converted.
info > timestamp
Returns the exact date and time (UNIX time stamp) the request was completed.
info > rate
Returns the exchange rate used for your conversion.
result
Returns your conversion result.

Convert From Smallest Unit Endpoint:

JavaScript Fetch

const url = 'https://api.currencies.dev/convert_currency?from=GBP&to=JPY&amount=25&api_key={YOUR_API_KEY}';

const options = {

method: 'GET'

}


try {

const response = await fetch(url, options);

const result = await response.text();

console.log(result);

} catch (error) {

console.error(error);

}