2017 © Pedro Peláez
 

library php-quandl

image

dannyben/php-quandl

  • Tuesday, June 12, 2018
  • by DannyB
  • Repository
  • 12 Watchers
  • 48 Stars
  • 3,058 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 0 Open issues
  • 10 Versions
  • 12 % Grown

The README.md

PHP Quandl

Latest Stable Version Build Status Maintainability, (*1)


This library provides easy access to the [Quandl API][1] using PHP., (*2)

It provides several convenience methods to common Quandl API endpoints, as well as a generic method to access any of Quandl's endpoints directly., (*3)


Geting Started

Include the Quandl.php class in your code, and run one of the examples., (*4)

To install with composer:, (*5)

$ composer require dannyben/php-quandl

Examples

This is a basic call. It will return a PHP object with price data for AAPL:, (*6)

$api_key = "YOUR_KEY_HERE";
$quandl = new Quandl($api_key);
$data = $quandl->getSymbol("WIKI/AAPL");

You may pass any parameter that is mentioned in the Quandl documentation:, (*7)

$quandl = new Quandl($api_key);
$data = $quandl->getSymbol($symbol, [
    "sort_order"      => "desc",
    "rows"            => 10,
    "column_index"    => 4, 
]);

The date range options get a special treatment. You may use any date string that PHP's strtotime() understands., (*8)

$quandl = new Quandl($api_key, "csv");
$data = $quandl->getSymbol($symbol, [
    "trim_start" => "today-30 days",
    "trim_end"   => "today",
]);

You can also search the entire Quandl database and get a list of supported symbols in a data source:, (*9)

$quandl = new Quandl($api_key);
$data = $quandl->getSearch("crude oil");
$data = $quandl->getList("WIKI", 1, 10);

To access any Quandl API endpoint directly, use the get method, (*10)

$quandl = new Quandl($api_key);
$data = $quandl->get("databases/WIKI");

More examples can be found in the examples.php file, (*11)

Caching

You may provide the quandl object with a cache handler function. This function should be responsible for both reading from your cache and storing to it., (*12)

See the example_cache.php file., (*13)

Reference

Constructor

The constructor accepts two optional parameters: $api_key and $format:, (*14)

$quandl = new Quandl("YOUR KEY", "csv");

You may also set these properties later (see below);, (*15)

Public Properties

$api_key

$quandl->api_key = "YOUR KEY";

Set your API key, (*16)

$format

$quandl->format = 'csv';

Set the output format. Can be: csv, xml, json, and object (which will return a php object obtained with json_decode())., (*17)

$force_curl

$quandl->force_curl = true;

Force download using curl. By default, we will try to download with file_get_contents if available, and fall back to curl only as a last resort., (*18)

$no_ssl_verify

$quandl->no_ssl_verify = true;

Disables curl SSL verification. Set to true if you get an error saying "SSL certificate problem"., (*19)

$timeout

$quandl->timeout = 60;

Set the timeout for the download operations., (*20)

$last_url

print $quandl->last_url;

Holds the last API URL as requested from Quandl, for debugging., (*21)

$error

print $quandl->error;

In case there was an error getting the data from Quandl, the request response will be false and this property will contain the error message., (*22)

$was_cached

print $quandl->was_cached;

When using a cache handler, this property will be set to true if the response came from the cache., (*23)

Methods

get

mixed get( string $path [, array $params ] )

// Examples
$data = $quandl->get( 'datasets/EOD/QQQ' );
$data = $quandl->get( 'datasets/EOD/QQQ', ['rows' => 5] );

Returns an object containing the response from any of Quandl's API endpoints. The format of the result depends on the value of $quandl->format., (*24)

The optional parameters array is an associative key => value array with any of the parameters supported by Quandl., (*25)

You do not need to pass auth_token in the array, it will be automatically appended., (*26)

getSymbol

mixed getSymbol( string $symbol [, array $params ] )

// Examples
$data = $quandl->getSymbol( 'WIKI/AAPL' );
$data = $quandl->getSymbol( 'WIKI/AAPL', ['rows' => 5] );

Returns an object containing data for a given symbol. The format of the result depends on the value of $quandl->format., (*27)

The optional parameters array is an associative key => value array with any of the parameters supported by Quandl., (*28)

You do not need to pass auth_token in the array, it will be automatically appended., (*29)

getSearch

mixed getSearch( string $query [, int $page, int $per_page] )

// Examples
$data = $quandl->getSearch( "gold" );
$data = $quandl->getSearch( "gold", 1, 10 );

Returns a search result object. Number of results per page is limited to 300 by default., (*30)

Note that currently Quandl does not support CSV response for this node so if $quandl->format is "csv", this call will return a JSON string instead., (*31)

getList

mixed getList( string $source [, int $page, int $per_page] )

// Examples
$data = $quandl->getList( 'WIKI' );
$data = $quandl->getList( 'WIKI', 1, 10 );

Returns a list of symbols in a given source. Number of results per page is limited to 300 by default., (*32)

getMeta

mixed getMeta( string $source )

// Example
$data = $quandl->getMeta( 'WIKI' );

Returns metadata about a symbol., (*33)

getDatabases

mixed getDatabases( [int $page, int $per_page] )

// Examples
$data = $quandl->getDatabases();
$data = $quandl->getDatabases( 1, 10 );

Returns a list of available databases. Number of results per page is limited to 100 by default., (*34)

getBulk

This feature is only supported with premium databases., (*35)

boolean getBulk( string $database, string $path [, boolean $complete] )

// Examples
boolean getBulk( 'EOD', 'eod-partial.zip' );
boolean getBulk( 'EOD', 'eod-full.zip', true );

Downloads the entire database and saves it to a ZIP file. If $complete is true (false by default), it will download the entire database, otherwise, it will download the last day only., (*36)

The Versions

12/06 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

22/06 2016

v0.5.2

0.5.2.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

17/05 2016

v0.5.1

0.5.1.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

14/05 2016

v0.5.0

0.5.0.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

12/05 2016

v0.4.0

0.4.0.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

10/04 2016

dev-dev

dev-dev

  Sources   Download

MIT

The Requires

  • php ~5.4

 

19/05 2015

v0.3.3

0.3.3.0

  Sources   Download

MIT

The Requires

  • php ~5.4

 

04/05 2015

v0.3.2

0.3.2.0

  Sources   Download

MIT

The Requires

  • php ~5.4

 

13/12 2014

v0.3.1

0.3.1.0

  Sources   Download

MIT

The Requires

  • php ~5.4

 

29/10 2014

v0.3.0

0.3.0.0

  Sources   Download

MIT

The Requires

  • php ~5.4