PHP Currency Converter Example

In this tutorial we are going to explain how to create currency converter in website. We found plenty of tutorials on internet related this, but they are not working or updated. Most of the recommend Google API for currency converter. Google has depreciate this API service and no longer use anymore.

We searched and found few paid API service who provide real time currency converter feature like, They have premium service and you have to take monthly subscription to get this API service.

In this tutorial, we are using API service to convert currency value from one currency type to other currency type. It is also paid API subscription, but they have Free version also.

currency converter api

This free version has some access limit. If you want to create Currency Converter for small scale website, than it would be good option for you.

Free Version API Limits:

Conversion Pairs per Request: 2
Number of Requests per Hour: 100
Date Range in History: 8 Days
Allowed Back in History: 1 Year(s)

PHP Currency Converter Script

In this script we are using currencyconverterapi free API by using file_get_contents() method. We have created a PHP ‘currencyConverter‘ function and send parameters like Amount, From currency, To currency.

$amount: Currancy amount you want to convert.
$from_currency: Use this parameters to input which currency you want to convert.
$to_currency: Use this parameters to pass currency value, in which it will convert.

Check below Currency Converter code:

This is the straight PHP Currency Converter example. You can implement on your website for live currancy conversion.

If you want more feature than you can go for Premium API version, which just start with $5 per month price.

Check Live Demo and Download Free Source code


Leave a Comment