Recommend this page to a friend!
  Classes of Jacob Davis  >  PHP Forex Quotes  >  >  Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Forex Quotes
Get foreign exchange rates quotes for currencies
Author: By
Last change: Merge pull request #8 from 1Forge/betaUpdate

V6.0.0 fix
V6.0.0 fix
Version Change and Socket Server Updated
Date: 4 months ago
Size: 3,239 bytes



Class file image Download


php-forex-quotes is a PHP Library for fetching realtime forex quotes. See the examples for REST and WebSocket implementation in the /examples folder.

<a href="#">1Forge Data</a>

Table of Contents


  • PHP >= 6.0.1
  • An API key which you can obtain for free at


composer require oneforge/forexquotes

Or in your composer.json

"require": {
    "oneforge/forexquotes": "^6.0"


Instantiate the client


use OneForge\ForexQuotes\ForexDataClient;

//You can get an API key for free at
$client = new ForexDataClient('YOUR_API_KEY');

Get the list of available symbols:


Get quotes for specified symbols:


Convert from one currency to another:

$client->convert('USD', 'EUR', 100);

Check if the market is open:

if ($client->marketIsOpen())
    echo "Market is open";    

Check your usage / quota limit:


Stream quote updates:

WebSocket quote streaming is only available on paid plans.

//Handle incoming price updates from the server
$client->onUpdate(function($symbol, $data)
    echo $symbol . ": " . $data["b"] . " " .$data["a"] . " " . $data["p"]."\n";

//Handle non-price update messages
    echo $message;

//Connect to the server
    //Subscribe to a single currency pair

    //Subscribe to an array of currency pairs

    //Subscribe to all currency pairs

    //Unsubscribe from a single currency pair

    //Unsubscribe from an array of currency pairs

    //Unsubscribe from all currency pairs



Thank you for considering contributing! Any issues, bug fixes, suggestions, improvements or help in any other way is always appreciated. Please feel free to open an issue or create a pull request.

Support and Contact

Please contact me at if you have any questions or requests.

License and Terms

This library is provided without warranty under the MIT license.

For more information send a message to info at phpclasses dot org.