# How to convert amounts to website visitor currency

In this tutorial we demonstrate how to convert amounts and prices on the fly to each of your website visitor's currency based on their IP address with client side Javascript code :

We will be using the currency conversion API along with the Geolocation API

Our Currency Conversion API endpoint is useful for applications where you just want to convert between two specific currencies and aren't interested in any others.

Using the `conversion` endpoint, you may request the IpForensics API to perform a Single currency conversion on your behalf. e.g converting `$500 Dollars to Naira`

You'll need to choose your base currency code, the target currency and the amount you'd like to get the exchange rate for.&#x20;

```javascript
var toCurrency = "USD" //currency to exchange to
var productAmount = 500; //product amount


// Getting the currency symbol from the user's IP
$.get("https://ipforensics.net/api/v1/origin?apikey=APIKEY", function (response) {
    //this will return the currency sysmbol e.g NG
    var fromCurency = response.meta_data.currency.symbol;
        
    //make another request to 
    $.get(`https://ipforensics.net/api/v1/currency/convert?apikey=YOUR-API-KEY&from=${fromCurency}&to=${toCurrency}&amount=${productAmount}`, function (response) {
    
        //shows the exchage rate
        console.log(response.meta_data.exchange_rate)
    
    }, "jsonp");
}, "jsonp");
```

**Checkout the** [**Currency Conversion Endpoint Documentation**](https://ipforensics.gitbook.io/ipforensics/api/exchange-rate-api/currency-swap-endpoint)

**You don't need to send the user IP Address, our system will automatically detect users IP address and return required data as response to your application.**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ipforensics.gitbook.io/ipforensics/code-implantation/how-to-convert-amounts-to-website-visitor-currency.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
