Free PHP Exchange Rate API

Welcome to the UnirateAPI PHP documentation! Our free exchange rate API provides real-time currency conversion capabilities that you can easily integrate into your PHP applications. Whether you're building a financial application, e-commerce platform, or any other system that needs currency conversion, our API has you covered.

UnirateAPI is designed to be developer-friendly and reliable, with a focus on simplicity and performance. Our PHP implementation uses native cURL for HTTP requests, making it compatible with any PHP environment without requiring additional dependencies. The API returns JSON responses that can be easily parsed using PHP's built-in JSON functions.

With UnirateAPI, you get:

  • Real-time exchange rates from reliable sources
  • Simple RESTful API endpoints
  • Support for 590+ currencies
  • Completely free with no credit card required
  • 99.9% uptime guarantee
  • Fast response times (avg. 50ms)
  • Automatic currency updates every hour

Our PHP implementation is designed to be:

  • Easy to integrate with minimal code changes
  • Compatible with PHP 7.0 and above
  • Error-resistant with proper exception handling
  • Memory efficient with streaming responses

For more detailed information about our API endpoints, rate limits, and advanced features, please check our main API documentation.

The example below shows you how to integrate our API into your PHP application in just a few lines of code.

Getting Started with php

Our Currency Convertor API is easy to integrate with PHP applications. Below you'll find a complete example of how to use our API.


// Example of using the Unirate API with PHP
$api_key = 'YOUR_API_KEY';
$base_url = 'https://api.unirateapi.com/api';

// Function to convert currency
function convertCurrency($from, $to, $amount) {
    global $api_key, $base_url;
    
    $url = "{$base_url}/convert?api_key={$api_key}&from={$from}&to={$to}&amount={$amount}";
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json'
    ]);
    
    $response = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    if ($http_code === 200) {
        return json_decode($response, true);
    } else {
        throw new Exception('API request failed: ' . $response);
    }
}

// Example usage
try {
    $result = convertCurrency('USD', 'EUR', 100);
    echo "Converted amount: " . $result['result'] . " " . $result['to'];
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

Response Example


{
    "from": "USD",
    "to": "EUR",
    "amount": 100,
    "result": 92.45,
}

Important Notes

  • Replace 'YOUR_API_KEY' with your actual API key
  • Make sure to handle API errors appropriately in production
  • Consider implementing rate limiting and caching for better performance
  • Use HTTPS for all API requests to ensure security
  • Store your API key securely and never commit it to version control
  • Check our rate limits and implement appropriate error handling

Ready to Get Started?

Sign up now to get your API key and start converting currencies in your php applications.

Get Your API Key