This bundle integrates the http://alphavantage.co/ Stock and Crypto API into Symfony 3/4/5.
- PHP 7.4+
- composer
- Alphavantage API-key, claim yours here
composer require cheesaw/alpha-vantage-bundle
Set your API-key into an env var
CHEESAW_ALPHA_VANTAGE_API_KEY=YOUR-API-KEY
Just use the client, it will be autowired by Symfony into your Services/Controllers
/**
* @Route("test/av/get", name="cheesaw_alphavantage_test")
* @throws Exception
*/
public function alphaVantageTestAction(AlphaVantage $alphaVantageClient): Response
{
$stockTimeSeries = new StockTimeSeries(StockTimeSeries::GLOBAL_QUOTE, 'BLDP');
$response = $alphaVantageClient->get($stockTimeSeries);
return new Response($response);
}
The code will output json:
{ "Global Quote": { "01. symbol": "BLDP", "02. open": "10.6200", "03. high": "10.9800", "04. low": "10.4500", "05. price": "10.9300", "06. volume": "1086884", "07. latest trading day": "2020-02-06", "08. previous close": "10.6300", "09. change": "0.3000", "10. change percent": "2.8222%" } }
- Fork this repository
- Write your code
- Create a new pull request
On any questions, send me a message!
- MIT license
- Copyright 2020 © Martin Tomala.