IpForensics
HomeGoto Dashboard
  • 📖Introduction
  • Protocols
    • HTTP Json Protocol
    • Response headers
    • Error Codes
  • Features
    • Pay-As-You-Go
    • API Security
    • HTTPS
  • Api Response Data
    • 📶Mobile Carrier
    • 🏥ASN
    • 📊General
    • ⏲️Timezone
    • 💵Currency
    • 👨‍💻Threat Detector
    • 🌐Company
    • 🌏Geolocation
    • 🌍Advance Geolocation
    • 💻Device Information
    • ✈️IATA/ICAO
  • API
    • 🚀Intro
    • 📊IP & Threat Intelligence API
      • Single Lookup
      • Origin Lookup
    • 💹Exchange Rate API
      • Currency Endpoint
      • Live Rate Endpoint
      • Historical Rate Endpoint
      • Currency Conversion Endpoint
      • Currency Swap Endpoint
  • Code Implantation
    • Block Automated Visits From Hosting Providers
    • Block VPN/Proxy and Tor users
    • Redirect by Country and Location Offers
    • Content Personalisation
    • Get the location from an IP Address in Javascript
    • How to get a client's IP address using JavaScript
    • HTML5 Geolocation with IpForensics fallback
    • Blocking Users by Country
    • Detecting Users Currency or Currency Personalisation
    • Preventing Free Trial Abuse
    • Device-Based Ads and App Binary
    • Detect Users Device/Computer and Operating System
    • Detect visitors from EU countries
    • How to detect and prevent credit card fraud
    • How to convert amounts to website visitor currency
  • MISC
    • Changelog
    • FAQs
    • Troubleshooting
    • API Status
    • Rate Limits
Powered by GitBook
On this page

Was this helpful?

  1. Code Implantation

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.

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");

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.

PreviousHow to detect and prevent credit card fraudNextChangelog

Last updated 2 years ago

Was this helpful?

Checkout the

Currency Conversion Endpoint Documentation