gieroj / barchart-api
Api integration with barchart stock market data.
Requires
- php: >=7.2.5
- guzzlehttp/guzzle: ~6.0
- nesbot/carbon: ^2.14
This package is auto-updated.
Last update: 2025-08-26 14:28:05 UTC
README
PHP package integration with Barchart API stock market data.
Instalation
To use repository add to your composer.json:
"require": {
"gieroj/barchart-api": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/gieroj/barchart-api"
}
]
and then
composer install
If you are using Laravel version older than 5.7 or any other Framework then you need to update your provider's list:
'providers' => [
// Add this on the end of list providers
Gieroj\BarchartApi\BarchartApiServiceProvider::class,
]
How to use it
First, we need to declare that we will use this package:
use Gieroj\BarchartApi\BarchartApi;
Now we are able to call API. For example to getQuote:
$barchart = new BarchartApi(env('BARCHART_KEY'), env('BARCHART_URL'));
$symbol = 'DRW';
$quote = $barchart->getQuote($symbol)->getResponse();
We can actually call to all available API from barchart. Lets call getHistory but we will use getCustom function to do that, in that way even if I did not cover specific endpoint you are still able to call to it.
$barchart = new BarchartApi(env('BARCHART_KEY'), env('BARCHART_URL'));
$options = ['symbol' => 'GOOG', 'type' => 'daily', 'startDate' => '2020-05-01'];
$response = $barchart->getCustom('getHistory', $options )->getResponse();
By changing query name and provide correct options we are able to call all available endpoints.
📈 enjoy