PHP Classes

PHP Stock Market API: Get data about stocks using the MarketStack API

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 136 All time: 9,267 This week: 63Up
Version License PHP version Categories
marketstack 1.0.0GNU General Publi...5PHP 5, Web services, Finances
Description 

Author

This class can get data about stocks using the MarketStack API.

It can send HTTP requests to the MarketStack API Web server to get several details of stocks listed in stock exchanges. Currently it can:

- Get the values of one or more stocks
- Get realtime values one or more stocks during the day
- Look up information about one or multiple stock ticker symbols
- Look up information about many stock exchanges
- Look up information about all supported currencies
- Look up information about all supported timezones.

Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 59
All time rank: 608 in United States United States
Week rank: 14 Up1 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Example

<?php
/*
example usage
marketStack ver 1.0

You must get an API key from https://marketstack.com/product
and enter it in the marketstack.class.php file

For complete documentation on each endpoint and available paramaters
see https://marketstack.com/documentation
*/

//turning off low level notices
error_reporting(E_ALL ^ E_NOTICE);

//instantiate the class
require('marketstack.class.php');
$market = new marketStack();

//get ticker information for Microsoft symbol MSFT
$market->setEndPoint('tickers','MSFT');
$market->getResponse();

echo
'<strong>'.$market->response->name.'</strong>'.' ('.$market->response->symbol.')'.'<br>';
echo
$market->response->stock_exchange->acronym.'<br>';

//get latest market activity for Microsoft
$market->setEndPoint('eod','latest');
$market->setParam('symbols','MSFT');
$market->getResponse();

$data = $market->response->data[0];

echo
'<hr>';
echo
'<strong>Date: </strong>'.$data->date.'<br>';
echo
'<strong>Open: </strong>$'.$data->open.'<br>';
echo
'<strong>High: </strong>$'.$data->high.'<br>';
echo
'<strong>Low: </strong>$'.$data->low.'<br>';
echo
'<strong>Close: $'.$data->close.'</strong><br>';

//list of supported exchanges
$market->setEndPoint('exchanges');
$market->getResponse();

echo
'<hr>';
echo
'<h4>Marketstack supports the following exchanges:</h4>';

foreach(
$market->response->data as $data ){
    echo
'<strong>'.$data->mic.'</strong> '.$data->name.' ('.$data->acronym.') '.$data->city.' - '.$data->country.'</br>';
}
?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example Usage
Accessible without login Plain text file license.txt Lic. License
Plain text file marketstack.class.php Class Main Class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:136
This week:0
All time:9,267
This week:63Up