PERL Forex Data Feed API

This Forex Data API is an Application Programming Interface that allows you to write custom applications using the PERL scripting language. PERL is a very common language enabled on most Webservers making this API an ideal choice for website owners or other applications where PERL is available.

This API is provided free of charge to all ForexFeed.net clients.

See the example below which makes use of the PERL Forex Data Feed API to handle all the underlying logic. As you can see the API greatly simplifies many use cases.

Note: this is very simple example using the Forex Data API. This script is designed to run on a web server and it prints data to the screen / web browser

#!/usr/bin/perl
use strict;

## Load the FXFeed API
use ForexFeed;

 
## Create the ForexFeed Object
 
my $fxfeed = new ForexFeed::feed(
                    
'-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
"Content-type: text/html;\r\n\r\n";
 
  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() eq "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";
   }