Skip to main content
Guides / Get the latest exchange rates
The full Spider logo.

Get the latest exchange rates

Get up-to-date exchange rates for 150+ currencies via a single API endpoint, useful for Stripe checkout conversions.

3 min read Jeff Mendez

If you price anything in more than one currency, you need rates that are current and that you did not have to source yourself. This guide covers the endpoint that returns exchange rates against the USD, and how to call it.

Introducing the exchange rates endpoint

Our exchange-rates API endpoint provides real-time exchange rates for over 150 currencies that are compatible with Stripe. By querying this endpoint, you can easily integrate it into your financial applications, e-commerce platforms, or any service that requires currency conversion.

Endpoint URL

You can fetch the exchange rates using the following client endpoint:

GET https://api.spider.cloud/data/exchange-rates?filter=usd,eur,gbp

This endpoint allows you to get exchange rates based on the USD price point, filtered by the specified currencies at 1 credit per call.

Example request

Here’s an example request where we are asking for exchange rates for USD, EUR, and GBP:

GET https://api.spider.cloud/data/exchange-rates?filter=usd,eur,gbp

Example response

The response from the endpoint will be a JSON object containing the exchange rates for the specified currencies. For instance:

{
  "content": {
    "usd": 1.0,
    "eur": 0.85,
    "gbp": 0.75
  }
}

Here, the exchange rates for EUR and GBP are provided relative to USD (which always has a value of 1.0).

How to use the API

To show you how simple it is to get the exchange rates, let’s use a sample client-side example using JavaScript to fetch data from our endpoint.

Step 1: make a GET request

Use JavaScript to send a GET request to the https://api.spider.cloud/data/exchange-rates endpoint.

async function getExchangeRates() {
  try {
    const response = await fetch('https://api.spider.cloud/data/exchange-rates?filter=usd,eur,gbp', { headers: { authorization: process.env.SPIDER_API_KEY } });
    const data = await response.json();
    console.log("Exchange Rates:", data.content);
  } catch (error) {
    console.error('Error fetching exchange rates:', error);
  }
}

// Execute the function
getExchangeRates();

Step 2: display the rates

You can then use the fetched data to display the rates on your web page or perform any other operation required.

<!DOCTYPE html>
<html>
<head>
  <title>Exchange Rates</title>
</head>
<body>
  <h1>Exchange Rates</h1>
  <div id="exchange-rates"></div>

  <script>
    async function getExchangeRates() {
      try {
        const response = await fetch('https://api.spider.cloud/data/exchange-rates?filter=usd,eur,gbp', { headers: { authorization: process.env.SPIDER_API_KEY }} );
        const data = await response.json();
        document.getElementById('exchange-rates').innerText = JSON.stringify(data.content, null, 2);
      } catch (error) {
        console.error('Error fetching exchange rates:', error);
      }
    }

    // Execute the function
    getExchangeRates();
  </script>
</body>
</html>

By following these simple steps, your web page will display the current exchange rates for the specified currencies.

Conclusion

One GET request to https://api.spider.cloud/data/exchange-rates returns rates for over 150 currencies, and it costs one credit. That covers checkout pricing, financial analysis, and anything else that has to convert between currencies.

For more details, see the API reference.

Run this on a page you care about

The playground sends the request this page describes and shows you the response. Keyless runs work without an account, capped at 25 a day.