ersindemirtas/polygonio-php-client

polygon.io php client

2.2.1 2020-09-06 14:07 UTC

This package is auto-updated.

Last update: 2021-02-05 23:48:54 UTC


README

This repository is a fork of polygon-io/client-php, the original repository is not been maintained properly so decided to maintain my own version. Feel free to contribute.

Installation guide

Prerequisite

Install

composer require ersindemirtas/polygonio-php-client

Rest API

The ErsinDemirtas\PolygonIO\Rest\Rest class export 4 modules:

  • reference
  • stocks
  • forex
  • crypto
<?php

require __DIR__ . '/vendor/autoload.php';

$rest = new ErsinDemirtas\PolygonIO\Rest\Rest('API_KEY');

$amount = 10;
var_dump($rest->forex->realTimeCurrencyConversion->get('USD', 'EUR', compact('amount')));

Websockets

The WebSocket clients use the Amp event loop. You can only use one WebSocket client by PHP thread since the event loop is in blocking while loop.

<?php

require __DIR__ . '/vendor/autoload.php';

$client = new ErsinDemirtas\PolygonIO\PolygonIO('API_KEY');

$currencies = ['XQ.BTC-USD'];

$client->websockets->crypto->connect($currencies, function($data) {
    var_dump($data);
});

Development

Prerequisite

Use the tooling

Install dependencies

composer require

Run the linter

composer lint

Run the tests

composer test