PHP code example of rocketfellows / tinkoff-invest-v1-rest-client

1. Go to this page and download the library: Download rocketfellows/tinkoff-invest-v1-rest-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rocketfellows / tinkoff-invest-v1-rest-client example snippets


public function request(string $serviceName, string $serviceMethod, array $data): array;

$client = new Client(
    (
        new ClientConfig(
            'https://invest-public-api.tinkoff.ru/rest',
            <your_access_token>
        )
    ),
    new \GuzzleHttp\Client()
);

$response = $client->request(
    'InstrumentsService',
    'GetDividends',
    [
        "figi" => "BBG004730RP0",
        "from" => "2022-05-28T15:38:52.283Z",
        "to" => '2022-08-18T15:38:52.283Z',
    ]
);

// response
array(1) {
  ["dividends"]=>
  array(1) {
    [0]=>
    array(9) {
      ["dividendNet"]=>
      array(3) {
        ["currency"]=>
        string(3) "rub"
        ["units"]=>
        string(2) "52"
        ["nano"]=>
        int(530000000)
      }
      ["declaredDate"]=>
      string(20) "2022-06-30T00:00:00Z"
      ["lastBuyDate"]=>
      string(20) "2022-07-18T00:00:00Z"
      ["dividendType"]=>
      string(0) ""
      ["recordDate"]=>
      string(20) "2022-07-20T00:00:00Z"
      ["regularity"]=>
      string(0) ""
      ["closePrice"]=>
      array(3) {
        ["currency"]=>
        string(3) "rub"
        ["units"]=>
        string(3) "297"
        ["nano"]=>
        int(0)
      }
      ["yieldValue"]=>
      array(2) {
        ["units"]=>
        string(2) "17"
        ["nano"]=>
        int(690000000)
      }
      ["createdAt"]=>
      string(27) "2022-06-06T02:04:47.759671Z"
    }
  }
}