finazon / finazon-grpc-php
Finazon gRPC client library for PHP
Requires
- php: ^7.4|^8.0
- ext-grpc: *
- ext-protobuf: *
- google/common-protos: ^4.5
- google/protobuf: ^3.25
- grpc/grpc: ^1.57
This package is auto-updated.
Last update: 2024-11-28 10:53:51 UTC
README
This is the official PHP library for Finazon, offering access to:
- Lists of datasets, publishers, markets, and tickers.
- Market data: ticker snapshots, time series, trades, and technical indicators.
- Data from specific datasets such as Benzinga, Binance, Crypto, Forex, SEC, and SIP.
🔑 API key is essential. If you haven't got one yet, sign up here.
Requirements
Ensure you have PHP 7.4 or later.
Installation
Add package using Composer
composer require finazon/finazon-grpc-php
🔗 View the package on Packagist.
Updating to last version
composer update finazon/finazon-grpc-php
Quick start
1. Set up a new project
mkdir hello-finazon && cd hello-finazon
composer init --name="example/hello-finazon" --no-interaction
composer require finazon/finazon-grpc-php
2. Create time_series.php
script
<?php require 'vendor/autoload.php'; use Finazon\Grpc\Api\GetTimeSeriesRequest; use Finazon\Grpc\Api\TimeSeries; use Finazon\Grpc\Exception\RequestException; use Finazon\Grpc\Service\TimeSeriesService; // Load last OHLCV candles for AAPL $service = new TimeSeriesService('your_api_key'); $request = new GetTimeSeriesRequest(); $request->setDataset('sip_non_pro') ->setTicker('AAPL') ->setInterval('1h') ->setPageSize(10); try { $response = $service->getTimeSeries($request); echo 'Last AAPL OHLCV data' . PHP_EOL; foreach ($response->getResult() as $t) { /** @var Timeseries $t */ echo sprintf( '%s - %s, %s, %s, %s, %s %s', $t->getTimestamp(), $t->getOpen(), $t->getHigh(), $t->getLow(), $t->getClose(), $t->getVolume(), PHP_EOL, ); } } catch (RequestException $e) { echo sprintf('Received error, code: %s, message: %s%s', $e->getCode(), $e->getMessage(), PHP_EOL); }
3. Input your API key
Replace 'your_api_key'
with your actual key.
4. Run script
php time_series.php
📝 Expected output:
Last AAPL OHLCV data
1709582400 - 175.325, 175.5, 174.95, 175.1, 14962271
1709578800 - 174.2, 175.645, 173.98, 175.325, 8209663
1709575200 - 174.05, 174.505, 173.79, 174.205, 7869144
1709571600 - 174.1112, 174.7, 174.01, 174.05, 7365810
1709568000 - 174.835, 175.895, 174.1, 174.1201, 8672800
1709564400 - 174.96, 175.929, 173.9, 174.83, 14265584
1709560800 - 176.15, 176.9, 174.62, 174.97, 13824038
1709323200 - 179.9312, 179.97, 179.415, 179.695, 7701993
1709319600 - 179.315, 180.22, 179.31, 180.005, 6668926
1709316000 - 178.515, 179.39, 178.33, 179.32, 6103415
👀 Check the full example and other examples here
RPC support
The following table outlines the supported rpc calls:
Here's how you can use service
and request
objects:
<?php require 'vendor/autoload.php'; use Finazon\Grpc\Api\RpcNameRequest; use Finazon\Grpc\Service\ServiceNameService; # ... $service = new ServiceNameService('your_api_key'); $request = new RpcNameRequest(); $response = service->rpcName($request);
Documentation
Delve deeper with our official documentation.
Examples
Explore practical scenarios in the examples directory.
Support
- 🌐 Visit our contact page.
- 🛠 Or our support center.
Stay updated
Contributing
- Fork and clone:
$ git clone https://github.com/finazon-io/finazon-grpc-php.git
. - Branch out:
$ cd finazon-grpc-php && git checkout -b my-feature
. - Commit changes and test.
- Push your branch and open a pull request with a comprehensive description.
For more guidance on contributing, see the GitHub Docs on GitHub.
License
This project is licensed under the MIT License. See the LICENSE.txt
file in this repository for more details.