PHPackages                             dzhdmitry/tinkoff-invest-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. dzhdmitry/tinkoff-invest-api

ActiveLibrary[API Development](/categories/api)

dzhdmitry/tinkoff-invest-api
============================

PHP client for Tinkoff Invest API

0.2.3(4y ago)102266MITPHPPHP ^7.4

Since Sep 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/dzhdmitry/tinkoff-invest-api)[ Packagist](https://packagist.org/packages/dzhdmitry/tinkoff-invest-api)[ RSS](/packages/dzhdmitry-tinkoff-invest-api/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (7)Versions (12)Used By (0)

PHP-клиент для API Тинькофф Инвестиций
======================================

[](#php-клиент-для-api-тинькофф-инвестиций)

[![Code Coverage](https://camo.githubusercontent.com/3ff36e51b79fbeb64ce459cc618c6faf350bd76cb37b5441bbca0ef382971500/68747470733a2f2f636f6465636f762e696f2f67682f647a68646d697472792f74696e6b6f66662d696e766573742d6170692f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/dzhdmitry/tinkoff-invest-api)

Позволяет делать запросы к [OpenAPI](https://tinkoff.github.io/invest-openapi/) сервиса Тинькофф Инвестиции на языке PHP. Формат данных, получаемых по REST API, полностью соответствует схеме, указанной в документации для REST API.

В REST-клиенте реализованы следующие методы [REST API](https://tinkoff.github.io/invest-openapi/swagger-ui/):

- sandbox
    - ✔ POST /sandbox/register
    - ✔ POST /sandbox/currencies/balance
    - ✔ POST /sandbox/positions/balance
    - ✔ POST /sandbox/remove
    - ✔ POST /sandbox/clear
- orders
    - ✔ GET /orders
    - ✔ POST /orders/limit-order
    - ✔ POST /orders/market-order
    - ✔ POST /orders/cancel
- portfolio
    - ✔ GET /portfolio
    - ✔ GET /portfolio/currencies
- market
    - ✔ GET /market/stocks
    - ✔ GET /market/bonds
    - ✔ GET /market/etfs
    - ✔ GET /market/currencies
    - ✔ GET /market/orderbook
    - ✔ GET /market/candles
    - ✔ GET /market/search/by-figi
    - ✔ GET /market/search/by-ticker
- operations
    - ✔ GET /operations
- user
    - ✔ GET /user/accounts

Также реализованы подписки на потоки данных по [streaming протоколу](https://tinkoff.github.io/invest-openapi/marketdata/):

- ✔ candle
- ✔ orderbook
- ✔ instrument\_info

Требования
----------

[](#требования)

- PHP 7.4+
- Composer

Установка
---------

[](#установка)

1. Установить клиент:

```
composer require dzhdmitry/tinkoff-invest-api
```

2. Выполнить [авторизацию](https://tinkoff.github.io/invest-openapi/auth/), выпустить токены OpenAPI для биржи и Sandbox

Использование
-------------

[](#использование)

```
// Пример 1. Получение списка акций
use Dzhdmitry\TinkoffInvestApi\Rest\ClientFactory;

// Создать клиент с токеном
$client = (new ClientFactory())->create('YOUR_TRADE_TOKEN');
// Сделать запрос на получение списка акций
$response = $client->market()->getStocks();

foreach ($response->getPayload()->getInstruments() as $instrument) {
    echo $instrument->getTicker() . "\n";
    echo $instrument->getName() . "\n";
    echo $instrument->getCurrency() . "\n";
}
```

```
// Пример 2. Получение портфеля клиента
use Dzhdmitry\TinkoffInvestApi\Rest\ClientFactory;

// Создать клиент с токеном
$client = (new ClientFactory())->create('YOUR_TRADE_TOKEN');
$brokerAccountId = 'your-broker-account-id';
// Сделать запрос на получение портфеля клиента по счету $brokerAccountId
$response = $client->portfolio()->get($brokerAccountId);

foreach ($response->getPayload()->getPositions() as $position) {
    echo $position->getInstrumentType() . "\n";
    echo $position->getTicker() . "\n";
    echo $position->getName() . "\n";
    echo $position->getBalance() . "\n";
}
```

```
// Пример 3. Создание лимитной заявки
use Dzhdmitry\TinkoffInvestApi\Rest\ClientFactory;
use Dzhdmitry\TinkoffInvestApi\Rest\Schema\Request\LimitOrderRequest;
use Dzhdmitry\TinkoffInvestApi\Rest\Schema\Enum\OperationType;

// Создать клиент с токеном
$client = (new ClientFactory())->create('YOUR_TRADE_TOKEN');
// Сделать запрос на создание лимитной заявки на счете "Тинькофф" (Заявка на покупку 5 лотов USD по цене 75.20)
$response = $client->orders()->postLimitOrder(
    'BBG0013HGFT4',
    new LimitOrderRequest(5, OperationType::BUY, 75.20)
);
$order = $response->getPayload();

echo $order->getOrderId() . "\n";
echo $order->getOperation() . "\n";
echo $order->getStatus() . "\n";
echo $order->getRequestedLots() . "\n";
echo $order->getExecutedLots() . "\n";
```

```
// Пример 4. Протокол Streaming
use Dzhdmitry\TinkoffInvestApi\Streaming\ResponseDeserializerFactory;
use Dzhdmitry\TinkoffInvestApi\Streaming\Schema\Payload\ErrorPayload;
use Dzhdmitry\TinkoffInvestApi\Streaming\Schema\Payload\Orderbook;
use Dzhdmitry\TinkoffInvestApi\Streaming\Schema\Request\OrderbookRequest;
use Dzhdmitry\TinkoffInvestApi\Streaming\Schema\Response\AbstractResponse;
use Dzhdmitry\TinkoffInvestApi\Streaming\Connection;
use Dzhdmitry\TinkoffInvestApi\Streaming\WebsocketConnectionFactory;

\Amp\Loop::run(function () {
    // Объект ResponseDeserializer можно использовать для десериализации ответов сервера
    $deserializer = (new ResponseDeserializerFactory())->create();

    // Connection предоставляет упрощенный доступ к управлению подписками на потоки данных
    $connection = new Connection(yield WebsocketConnectionFactory::create('YOUR_TRADE_TOKEN'));

    // Подписка на информацию биржевой стакан по акциям Apple
    $connection->subscribe(new OrderbookRequest('BBG000B9XRY4', 4));

    $i = 0;

    while ($message = yield $connection->receive()) {
        /** @var \Amp\Websocket\Message $message   полученное из WebSocket сообщение */
        /** @var AbstractResponse       $response  десериализованное тело сообщения */
        $response = $deserializer->deserialize(yield $message->buffer());

        echo $response->getEvent() . ' at ' . $response->getTime()->format(DATE_RFC3339) . "\n";

        if ($response->getPayload() instanceof ErrorPayload) {
            echo ' - error: ' . $response->getPayload()->getError() . "\n";
        } elseif ($response->getPayload() instanceof Orderbook) {
            echo ' - figi: ' . $response->getPayload()->getFigi() . "\n";
            echo ' - bids: ' . count($response->getPayload()->getBids()) . "\n";
            echo ' - asks: ' . count($response->getPayload()->getAsks()) . "\n";
        }

        if (++$i >= 4) {
            // Закрыть соединение при получении 4 ответов
            $connection->close();

            break;
        }

        // Получать каждое сообщение с интервалом в 1 сек
        yield \Amp\delay(1000);
    }
});
```

Лицензия
--------

[](#лицензия)

Распространяется под лицензией [MIT](https://raw.githubusercontent.com/dzhdmitry/tinkoff-invest-api/master/LICENSE)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~50 days

Recently: every ~74 days

Total

11

Last Release

1562d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1748814?v=4)[Dmitry Dzhuleba](/maintainers/dzhdmitry)[@dzhdmitry](https://github.com/dzhdmitry)

---

Top Contributors

[![dzhdmitry](https://avatars.githubusercontent.com/u/1748814?v=4)](https://github.com/dzhdmitry "dzhdmitry (40 commits)")

---

Tags

phpsdktinkoff-investtinkoff-sdk

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dzhdmitry-tinkoff-invest-api/health.svg)

```
[![Health](https://phpackages.com/badges/dzhdmitry-tinkoff-invest-api/health.svg)](https://phpackages.com/packages/dzhdmitry-tinkoff-invest-api)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[googleads/googleads-php-lib

Google Ad Manager SOAP API Client Library for PHP

67410.3M25](/packages/googleads-googleads-php-lib)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
