PHPackages                             james.rus52/tinkoffinvest - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. james.rus52/tinkoffinvest

ActiveLibrary[HTTP &amp; Networking](/categories/http)

james.rus52/tinkoffinvest
=========================

PHP client Tinkoff Invest

1.2.3(4y ago)682.9k↓76.9%9[1 issues](https://github.com/jamesRUS52/tinkoff-invest/issues)MITPHPPHP &gt;=5.6CI failing

Since Sep 11Pushed 4y ago8 watchersCompare

[ Source](https://github.com/jamesRUS52/tinkoff-invest)[ Packagist](https://packagist.org/packages/james.rus52/tinkoffinvest)[ RSS](/packages/jamesrus52-tinkoffinvest/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (2)Versions (23)Used By (0)

PHP client for Tinkoff invest API (PHP клиент для API Тинькофф инвестиции)
==========================================================================

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

[![](https://github.com/jamesRUS52/tinkoff-invest/workflows/Tests/badge.svg)](https://github.com/jamesRUS52/tinkoff-invest/workflows/Tests/badge.svg)

How to install
--------------

[](#how-to-install)

```
composer require james.rus52/tinkoffinvest

```

or add to your compose.json

```
{
    "require": {
        "james.rus52/tinkoffinvest": "^1.*"
    }
}
```

and then

```
composer install

```

How to use
----------

[](#how-to-use)

Include classes via autoloader

```
require_once 'vendor/autoload.php';

use \jamesRUS52\TinkoffInvest\TIClient;
use \jamesRUS52\TinkoffInvest\TISiteEnum;
use \jamesRUS52\TinkoffInvest\TICurrencyEnum;
use \jamesRUS52\TinkoffInvest\TIInstrument;
use \jamesRUS52\TinkoffInvest\TIPortfolio;
use \jamesRUS52\TinkoffInvest\TIOperationEnum;
use \jamesRUS52\TinkoffInvest\TIIntervalEnum;
use \jamesRUS52\TinkoffInvest\TICandleIntervalEnum;
use \jamesRUS52\TinkoffInvest\TICandle;
use \jamesRUS52\TinkoffInvest\TIOrderBook;
use \jamesRUS52\TinkoffInvest\TIInstrumentInfo;
```

create token to use tinkoff invest on [Tinkoff invest setting page](https://www.tinkoff.ru/invest/settings/)

Create client instance for sandbox

```
$client = new TIClient("TOKEN",TISiteEnum::SANDBOX);
```

or real exchange

```
$client = new TIClient("TOKEN",TISiteEnum::EXCHANGE);
```

Put money to your sandbox account (sandbox only)

```
$client->sbCurrencyBalance(500,TICurrencyEnum::USD);
```

Client register on sandbox (sandbox only)

```
$client->sbRegister();
```

Client remove account on sandbox (sandbox only)

```
$client->sbRemove();
```

Put stocks to your sandbox account (sandbox only)

```
$client->sbPositionBalance(10.4,"BBG000BR37X2");
```

Clear all positions on sandbox (sandbox only)

```
$client->sbClear();
```

Get all stocks/bonds/etfs/currencies from market

```
$stockes = $client->getStocks();
$instr = $client->getBonds();
$instr = $client->getEtfs();
$instr = $client->getCurrencies();
```

or with filter

```
$stockes = $client->getStocks(["V","LKOH"]);
$instr = $client->getBonds(["RU000A0JX3X7"]);
$instr = $client->getEtfs(["FXRU"]);
$instr = $client->getCurrencies(["USD000UTSTOM"]);
```

Get instrument by ticker

```
$instr = $client->getInstrumentByTicker("AMZN");
```

or by figi

```
$instr = $client->getInstrumentByFigi("BBG000BR37X2");
```

Get history OrderBook

```
$book = $client->getHistoryOrderBook("BBG000BR37X2", 1);
```

Get historical Candles

```
$from = new \DateTime();
$from->sub(new \DateInterval("P7D"));
$to = new \DateTime();
$candles = $client->getHistoryCandles("BBG000BR37X2", $from, $to, TIIntervalEnum::MIN15);
```

Get accounts

```
$accounts = $client->getAccounts();
```

Get portfolio (if null, used default Tinkoff account)

```
$port = $client->getPortfolio(TIAccount $account = null);
```

Get portfolio balance

```
print $port->getCurrencyBalance(TICurrencyEnum::RUB);
```

Get instrument lots count

```
print $port->getinstrumentLots("PGR");
```

Send limit order (default brokerAccountId = Tinkoff)

```
$order = $client->sendOrder("BBG000BVPV84", 1, TIOperationEnum::BUY, 1.2);
print $order->getOrderId();
```

Send market order (default brokerAccountId = Tinkoff)

```
$order = $client->sendOrder("BBG000BVPV84", 1, TIOperationEnum::BUY);
print $order->getOrderId();
```

Cancel order

```
$client->cancelOrder($order->getOrderId());
```

List of operations from 10 days ago to 30 days period

```
$from = new \DateTime();
$from->sub(new \DateInterval("P7D"));
$to = new \DateTime();
$operations = $client->getOperations($from, $to);
foreach ($operations as $operation)
  print $operation->getId ().' '.$operation->getFigi (). ' '.$operation->getPrice ().' '.$operation->getOperationType().' '.$operation->getDate()->format('d.m.Y H:i')."\n";
```

Getting instrument status

```
$status = $client->getInstrumentInfo($sber->getFigi());
print 'Instrument status: '. $status->getTrade_status()."\n";
```

Get Candles and Order books

```
if ($status->getTrade_status()=="normal_trading")
{
        $candle = $client->getCandle($sber->getFigi(), TICandleIntervalEnum::DAY);
        print 'Low: '.$candle->getLow(). ' High: '.$candle->getHigh().' Open: '.$candle->getOpen().' Close: '.$candle->getClose().' Volume: '.$candle->getVolume()."\n";

        $orderbook = $client->getOrderBook($sber->getFigi(),2);
        print 'Price to buy: '.$orderbook->getBestPriceToBuy().' Available lots: '.$orderbook->getBestPriceToBuyLotCount().' Price to Sell: '.$orderbook->getBestPriceToSell().' Available lots: '.$orderbook->getBestPriceToSellLotCount()."\n";
}
```

You can also to subscribe on changes order books, candles or instrument info: First of all, make a callback function to manage events:

```
function action($obj)
{
        print "action\n";
        if ($obj instanceof TICandle)
            print 'Time: '.$obj->getTime ()->format('d.m.Y H:i:s').' Volume: '.$obj->getVolume ()."\n";
        if ($obj instanceof TIOrderBook)
            print 'Price to Buy: '.$obj->getBestPriceToBuy().' Price to Sell: '.$obj->getBestPriceToSell()."\n";
}
```

Then subscribe to events

```
$client->subscribeGettingCandle($sber->getFigi(), TICandleIntervalEnum::MIN1);
$client->subscribeGettingOrderBook($sber->getFigi(), 2);
```

and finaly start listening new events

```
$client->startGetting("action",20,60);
```

in this example we awaiting max 20 respnse and max for 60 seconds if you want no limits, you should make

```
$client->startGetting("action");
$client->startGetting("action",null,600);
$client->startGetting("action",1000,null);
```

to stop listening do

```
$client->stopGetting();
```

\###CAUTION If you use subscriptions you should check figi on response, because you getting all subscribed instruments in one queue

Donation
--------

[](#donation)

Please support my project

[![](https://camo.githubusercontent.com/b109a46ceaa5f20be2239c27a57293deb68b68dd6c09fc2424520bc9df9b60bb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4WEWSZPBUBSVJ&source=url)[![](https://camo.githubusercontent.com/8a7bd7fa587f4417fd223ccdab0f875647349b64511fe3bbc9469d120ab0b4f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d59616e6465782d677265656e)](https://money.yandex.ru/quickpay/shop-widget?writer=seller&targets=Project%20support&targets-hint=&default-sum=100&button-text=14&payment-type-choice=on&mobile-payment-type-choice=on&hint=&successURL=&quickpay=shop&account=41001102505770)[![](https://camo.githubusercontent.com/40fa0d0ee5cd03cb0f5148febbf9961f51a2343ce95bd3e7f142be2b0a28cc09/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d5765624d6f6e65792d677265656e)](https://funding.webmoney.ru/widgets/horizontal/f892576d-1ce5-4046-abd7-7c947a81b398?hs=1&bt=0&sum=100)

Licence
-------

[](#licence)

MIT

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 59.8% 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 ~33 days

Recently: every ~40 days

Total

22

Last Release

1819d ago

Major Versions

0.6.1 → 1.02020-04-24

PHP version history (2 changes)0.1PHP ^5.6 || ^7.0

1.2PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/a64ca777106023ca0997b82cf8bce53932d67b442b16154d859bbd15fe9f2171?d=identicon)[jamesRUS52](/maintainers/jamesRUS52)

---

Top Contributors

[![jamesRUS52](https://avatars.githubusercontent.com/u/39707635?v=4)](https://github.com/jamesRUS52 "jamesRUS52 (55 commits)")[![acidmax76](https://avatars.githubusercontent.com/u/11664811?v=4)](https://github.com/acidmax76 "acidmax76 (28 commits)")[![neonll](https://avatars.githubusercontent.com/u/51386995?v=4)](https://github.com/neonll "neonll (5 commits)")[![denismosolov](https://avatars.githubusercontent.com/u/3057626?v=4)](https://github.com/denismosolov "denismosolov (2 commits)")[![fps01](https://avatars.githubusercontent.com/u/2114997?v=4)](https://github.com/fps01 "fps01 (1 commits)")[![xpundel](https://avatars.githubusercontent.com/u/1384653?v=4)](https://github.com/xpundel "xpundel (1 commits)")

---

Tags

phpclientrestinvesttinkoff

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jamesrus52-tinkoffinvest/health.svg)

```
[![Health](https://phpackages.com/badges/jamesrus52-tinkoffinvest/health.svg)](https://phpackages.com/packages/jamesrus52-tinkoffinvest)
```

###  Alternatives

[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4641.1k](/packages/ismaeltoe-osms)[wormling/phparia

Asterisk REST Interface (ARI) client for PHP.

419.8k](/packages/wormling-phparia)

PHPackages © 2026

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