PHP Classes
elePHPant
Icontem

PHP Forex Quotes: Get foreign exchange rates quotes for currencies

Recommend this page to a friend!
  Info   View files Documentation   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-09-20 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 30 All time: 9,085 This week: 556Up
Version License PHP version Categories
forexquotes 1.0MIT/X Consortium ...5.4Finances, PHP 7
Description Author

This package can get foreign exchange rates quotes for currencies.

It can send HTTP requests to the 1forge.com API to get the list of supported currency symbols.

The class can also get quotes for exchange of given currencies.

  Performance   Level  
Name: Jacob Davis <contact>
Classes: 1 package by
Country: United States United States
Age: ???
All time rank: 4149466 in United States United States
Week rank: 916 Up89 in United States United States Up

Details

php-forex-quotes

php-forex-quotes is a PHP Library for fetching realtime forex quotes

Table of Contents

Requirements

  • PHP >= 5.6.4
  • An API key which you can obtain for free at http://1forge.com/forex-data-api

Installation

composer require oneforge/forexquotes

Or in your composer.json

"require": {
    "oneforge/forexquotes": "2.0.3"
},

Usage

Instantiate the client

use OneForge\ForexQuotes\ForexDataClient;

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

Get the list of available symbols:

<?php

use OneForge\ForexQuotes\ForexDataClient;

$client = new ForexDataClient('YOUR_API_KEY');

/*
    Returns an array of symbols, eg: ['EURUSD', 'GBPJPY']
*/
$client->getSymbols(); 

Get quotes for specified symbols:

<?php

use OneForge\ForexQuotes\ForexDataClient;

$client = new ForexDataClient('YOUR_API_KEY');

/* 
Returns an array of quotes, eg: 
 [
     [
       "symbol" => "EURUSD",
       "price" => 1.11725,
       "timestamp" => 1496190844,
     ],
     [
       "symbol" => "GBPJPY",
       "price" => 142.037,
       "timestamp" => 1496190844,
     ],
   ]
*/   
$client->getQuotes([
    'AUDUSD',
    'GBPJPY'
]);

Convert from one currency to another:

<?php

use OneForge\ForexQuotes\ForexDataClient;

$client = new ForexDataClient('YOUR_API_KEY');

/* 
 
     [value] => 111.961
     [text] => 100 EUR is worth 111.961 USD
     [timestamp] => 1497187505
 
*/   
$client->convert('USD', 'EUR', 100);

Check if the market is open:

<?php

use OneForge\ForexQuotes\ForexDataClient;

$client = new ForexDataClient('YOUR_API_KEY');

/* 
    Returns an boolean
*/   

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

Check your usage / quota limit:

<?php

use OneForge\ForexQuotes\ForexDataClient;

$client = new ForexDataClient('YOUR_API_KEY');

/* 
    [quota_used]        => 53232,
    [quota_limit]       => 100000,
    [quota_remaining]   => 46768,
    [hours_until_reset] => 11
    
*/   

$client->quota();

Support and Contact

Please contact me at contact@1forge.com if you have any questions or requests.

License and Terms

This library is provided without warranty under the MIT license.

  Files folder image Files  
File Role Description
Files folder imagelib (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file example.php Aux. Auxiliary script
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  lib  
File Role Description
  Accessible without login Plain text file ForexDataClient.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:30
This week:0
All time:9,085
This week:556Up