实现/tinkoff-invest-openapi-php-sdk

20.2 2020-08-01 12:39 UTC

This package is auto-updated.

Last update: 2024-09-19 03:19:25 UTC


README

tinkoff.ru/invest OpenAPI.

此PHP包是由Swagger Codegen项目自动生成的

  • API版本:1.0.0
  • 构建包:io.swagger.codegen.v3.generators.php.PhpClientCodegen

要求

PHP 5.5及以上

安装与使用

Composer

要通过Composer安装绑定,请在composer.json中添加以下内容

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/realization/tinkoff-invest-openapi-php-sdk.git"
    }
  ],
  "require": {
    "realization/tinkoff-invest-openapi-php-sdk": "*@dev"
  }
}

然后运行composer install

手动安装

下载文件并包含autoload.php

    require_once('/path/to/SwaggerClient-php/vendor/autoload.php');

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门

请遵循安装过程,然后运行以下操作

<?php
require_once(__DIR__ . '/vendor/autoload.php');


$apiInstance = new Swagger\Client\Api\MarketApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->marketBondsGet();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling MarketApi->marketBondsGet: ', $e->getMessage(), PHP_EOL;
}


$apiInstance = new Swagger\Client\Api\MarketApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$figi = "figi_example"; // string | FIGI
$from = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Начало временного промежутка
$to = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | Конец временного промежутка
$interval = new \Swagger\Client\Model\CandleResolution(); // \Swagger\Client\Model\CandleResolution | Интервал свечи

try {
    $result = $apiInstance->marketCandlesGet($figi, $from, $to, $interval);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling MarketApi->marketCandlesGet: ', $e->getMessage(), PHP_EOL;
}


$apiInstance = new Swagger\Client\Api\MarketApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->marketCurrenciesGet();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling MarketApi->marketCurrenciesGet: ', $e->getMessage(), PHP_EOL;
}


$apiInstance = new Swagger\Client\Api\MarketApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->marketEtfsGet();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling MarketApi->marketEtfsGet: ', $e->getMessage(), PHP_EOL;
}


$apiInstance = new Swagger\Client\Api\MarketApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$figi = "figi_example"; // string | FIGI
$depth = 56; // int | Глубина стакана [1..20]

try {
    $result = $apiInstance->marketOrderbookGet($figi, $depth);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling MarketApi->marketOrderbookGet: ', $e->getMessage(), PHP_EOL;
}


$apiInstance = new Swagger\Client\Api\MarketApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$figi = "figi_example"; // string | FIGI

try {
    $result = $apiInstance->marketSearchByFigiGet($figi);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling MarketApi->marketSearchByFigiGet: ', $e->getMessage(), PHP_EOL;
}


$apiInstance = new Swagger\Client\Api\MarketApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$ticker = "ticker_example"; // string | Тикер инструмента

try {
    $result = $apiInstance->marketSearchByTickerGet($ticker);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling MarketApi->marketSearchByTickerGet: ', $e->getMessage(), PHP_EOL;
}


$apiInstance = new Swagger\Client\Api\MarketApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->marketStocksGet();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling MarketApi->marketStocksGet: ', $e->getMessage(), PHP_EOL;
}
?>

API端点文档

所有URI均相对于https://api-invest.tinkoff.ru/openapi/

模型文档

授权文档

sso_auth

  • 类型:HTTP承载身份验证

作者

n.v.melnikov@tinkoff.ru