composer require atepam/laravel-alphavantage-client
php artisan vendor:publish --provider="Atepam\AlphavantageClient\Providers\LatestPriceClientProvider" --tag="config"
https://www.alphavantage.co/documentation/#latestprice
Via facade
$data = AVLatestPrice::getLatestPrice('IBM');
Or via DI container
<?php
namespace App;
use Atepam\AlphavantageClient\Services\LatestPrice;
class ThisIsTheClass
{
public function __construct(
public readonly LatestPrice $avLatestPrice,
)
{
//
}
public function getLatestPrice(string $symbol): array
{
return $this->avLatestPrice->getLatestPrice($symbol);
}
}
Or instantiate
use Atepam\AlphavantageClient\Services\LatestPrice;
$client = app(LatestPrice::class);
$data = $client->getLatestPrice('IBM');