PHP code example of d1am0nd / alpha-vantage

1. Go to this page and download the library: Download d1am0nd/alpha-vantage library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

d1am0nd / alpha-vantage example snippets


// Daily historical data for Bitcoin to USD
$res = \AlphaVantage\Api::digitalCurrency()->daily('BTC', 'USD');
/* Returns
[
    "Meta Data": [
        "1. Information": "Daily Prices and Volumes for Digital Currency", ...
    ],
    "Time Series (Digital Currency Daily)": [
        "2018-01-03": [
            "1a. open (USD)": "14782.09572045", ...
        ],
        "2018-01-02": [
            "1a. open (USD)": "13514.39967186", ...
        ], ...
    ],
]
*/

use AlphaVantage\Api;
// ...
public function monthlyData()
{
    return Api::stock()->monthly('MSFT');
}

use AlphaVantage\Api;
// ...
public function currencyExchangeRate()
{
    return Api::currency()->currencyExchangeRate('EUR', 'USD');
}

use AlphaVantage\Api;
// ...
public function monthlyData()
{
    return Api::digitalCurrency()->monthly('BTC', 'USD');
}

use AlphaVantage\Api;
// ...
public function sectorPerformances()
{
    return Api::sector()->sectors();
}

use AlphaVantage\Api;
// ...
public function technicalIndicators()
{
    return Api::general()->query('MACDEXT', [
        'symbol' => 'MSFT',
        'interval' => '15min',
        'series_type' => 'high',
    ]);
}