This Forex Data API (Application Programming Interface) is a powerful tool which allows you to write custom applications using the PHP scripting language. PHP is a very common language enabled on most Webservers making this API an ideal choice for website owners.
Use it to create daily, hourly, minute, or real-time currency rate tables, integrate into your online shopping cart, or just retrieve the latest exchange rates for any (or all) crosses in the currency databases. This portable PHP API greatly simplifies the retrieval and parsing of raw currency data. Just call the various helper functions and away you go.
This API is provided free of charge to all ForexFeed.net customers.
See an example below of the PHP Forex Data Feed API in action. The API handles all the underlying logic so you can be up and running in no time.
Note: this is very simple example using the Forex Data API. This script is designed to run on a web server, it simply prints data to the screen / web browser. You can download this script (and the API) from the client area, or below if you are logged in.
If you need help with API integration we may be able to help. Give us a shout to talk to an experienced developer!
Use it to create daily, hourly, minute, or real-time currency rate tables, integrate into your online shopping cart, or just retrieve the latest exchange rates for any (or all) crosses in the currency databases. This portable PHP API greatly simplifies the retrieval and parsing of raw currency data. Just call the various helper functions and away you go.
This API is provided free of charge to all ForexFeed.net customers.
See an example below of the PHP Forex Data Feed API in action. The API handles all the underlying logic so you can be up and running in no time.
Note: this is very simple example using the Forex Data API. This script is designed to run on a web server, it simply prints data to the screen / web browser. You can download this script (and the API) from the client area, or below if you are logged in.
If you need help with API integration we may be able to help. Give us a shout to talk to an experienced developer!
<?php
/* Load the FXFeed API */
require_once('ForexFeed.class.php');
// Create the ForexFeed Object
$fxfeed = new ForexFeed(
array(
'access_key' => 'YOUR_ACCESS_KEY',
'symbol' => 'AUDUSD,EURUSD,GBPJPY,GBPUSD,USDCAD,USDCHF,USDJPY',
'interval' => 3600, // Specify the OHLC data interval in seconds (60 = 1 min bars, 300 = 5 min, 3600 = 1 hour, 86400 = 1 day, etc)
'periods' => 1, // Specify how many data periods to retrieve, in the above Interval (for each currency)
)
);
// Request the Data
$fxfeed->getData();
print "Number of Quotes: " . $fxfeed->getNumQuotes() . "<br><br>\n";
print "Copyright: " . $fxfeed->getCopyright() . "<br>\n";
print "Website: " . $fxfeed->getWebsite() . "<br>\n";
print "License: " . $fxfeed->getLicense() . "<br>\n";
print "Redistribution: " . $fxfeed->getRedistribution() . "<br>\n";
print "AccessPeriod: " . $fxfeed->getAccessPeriod() . "<br>\n";
print "AccessPerPeriod: " . $fxfeed->getAccessPerPeriod() . "<br>\n";
print "AccessThisPeriod: " . $fxfeed->getAccessThisPeriod() . "<br>\n";
print "AccessRemainingThisPeriod: " . $fxfeed->getAccessPeriodRemaining() . "<br>\n";
print "AccessPeriodBegan: " . $fxfeed->getAccessPeriodBegan() . "<br>\n";
print "NextAccessPeriodStarts: " . $fxfeed->getAccessPeriodStarts() . "<br>\n";
print "<br>\n";
if( $fxfeed->getStatus() == "OK" ){
// Loop though all the quotes
while( $fxfeed->iterator() ){
print " Symbol: " . $fxfeed->iteratorGetSymbol();
print " Title: " . $fxfeed->iteratorGetTitle();
if( $fxfeed->getInterval() == 1 ){
print " Bid: " . $fxfeed->iteratorGetBid();
print " Ask: " . $fxfeed->iteratorGetAsk();
}
else{
print " Time: " . $fxfeed->iteratorGetTimestamp();
print " Open: " . $fxfeed->iteratorGetOpen();
print " High: " . $fxfeed->iteratorGetHigh();
print " Low: " . $fxfeed->iteratorGetLow();
print " Close: " . $fxfeed->iteratorGetClose();
}
print "<br>\n";
}
}
else{
print "Status: " . $fxfeed->getStatus() . "<br>\n";
print "ErrorCode: " . $fxfeed->getErrorCode() . "<br>\n";
print "ErrorMessage: " . $fxfeed->getErrorMessage() . "<br>\n";
}
?>Downloads:
