Открытый банк (tbank.business)

Открытый банковский API Т-Бизнеса (T-API): счета и выписки, рублёвые платежи, инвойсы, СБП-ссылки.

  • Хосты: https://business.tbank.ru/openapi (чтение), https://secured-openapi.tbank.ru (движение денег, mTLS); sandbox=True — песочница.

  • Аутентификация: Bearer и mTLS

  • Суммы: Decimal в рублях

  • Клиенты: tbank.business.BusinessClient (async) и tbank.business.sync.BusinessClient (sync).

Счета и выписки

from datetime import datetime, timezone
from tbank.business import BusinessClient
from tbank.business.models import StatementParams, BankStatementParams
from datetime import date

client = BusinessClient(token="...")

accounts = await client.get_accounts()                 # счета + балансы

# выписка операций с курсорной авто-пагинацией:
params = StatementParams(account_number="40802...",
                         from_=datetime(2026, 1, 1, tzinfo=timezone.utc))
async for op in client.iter_statement(params):
    print(op.operation_id, op.operation_amount)

# одна страница или выписка за период:
page = await client.get_statement(params)              # page.operations, page.next_cursor
stmt = await client.get_bank_statement(
    BankStatementParams(account_number="40802...", from_=date(2026, 1, 1), till=date(2026, 1, 31))
)

Рублёвый платёж (mTLS)

from decimal import Decimal
from tbank.business.models import (
    CreatePaymentRequest, PaymentFrom, ReceiverRequisites, TaxPaymentParameters,
)

client = BusinessClient(token="...", cert=("client.pem", "key.pem"))

pid = await client.create_ruble_payment(CreatePaymentRequest(
    from_=PaymentFrom(account_number="40802..."),
    to=ReceiverRequisites(name="ООО Ромашка", inn="7700000000",
                          account_number="40702...", bik="044525974"),
    purpose="Оплата по счёту 1", amount=Decimal("12345.67"),
    # tax=TaxPaymentParameters(...) — для налогов/взносов
))
status = await client.get_payment_status(pid)          # mTLS
await client.get_documents_status([pid])               # батч-статусы (обычный хост)

Примечание

id платежа — ключ идемпотентности; если не передать, генерируется автоматически.

Инвойсы и СБП-ссылки

from decimal import Decimal
from tbank.business.models import SendInvoiceRequest, InvoiceItem, CreateOnetimeQrRequest

inv = await client.send_invoice(SendInvoiceRequest(
    invoice_number="101",
    items=[InvoiceItem(name="Товар", price=Decimal("100.50"), unit="шт",
                       vat="20", amount=Decimal("2"))],
))
await client.get_invoice_info(inv.invoice_id)          # DRAFT / SUBMITTED / EXECUTED

qr = await client.create_onetime_qr(
    CreateOnetimeQrRequest(sum=Decimal("1500.00"), purpose="Оплата", ttl=3)
)
print(qr.payment_url)

Клиент

class tbank.business.aio.BusinessClient(token, *, base_url=None, secured_base_url=None, sandbox=False, cert=None, verify=True, retry=None, transport=None, secured_transport=None)[исходный код]

Базовые классы: BaseAsyncClient

Асинхронный клиент T-API (открытый банк Т-Бизнес): счета и выписки.

Параметры:
decimal_body: ClassVar[bool] = True

True → тело парсится с parse_float=Decimal (точные денежные суммы).

async get_accounts()[исходный код]

Список счетов с балансами.

Тип результата:

List[Account]

async get_statement(params)[исходный код]

Одна страница выписки операций (курсорная пагинация).

Параметры:

params (StatementParams)

Тип результата:

StatementPage

async iter_statement(params)[исходный код]

Все операции выписки: автоматически следует за nextCursor.

Параметры:

params (StatementParams)

Тип результата:

AsyncIterator[StatementOperation]

async get_bank_statement(params)[исходный код]

Выписка за период: сальдо, обороты и операции.

Параметры:

params (BankStatementParams)

Тип результата:

BankStatement

async create_ruble_payment(payment)[исходный код]

Исполнить рублёвый платёж (mTLS). Возвращает id платежа (ключ идемпотентности).

Параметры:

payment (CreatePaymentRequest)

Тип результата:

str

async get_payment_status(payment_id)[исходный код]

Статус платежа по его id (mTLS).

Параметры:

payment_id (str)

Тип результата:

PaymentStatusResponse

async get_documents_status(document_ids)[исходный код]

Статусы пачки документов по их id (обычный хост).

Параметры:

document_ids (List[str])

Тип результата:

DocumentsStatusResponse

async send_invoice(request)[исходный код]

Выставить счёт клиенту (вернёт invoiceId и ссылку на PDF).

Параметры:

request (SendInvoiceRequest)

Тип результата:

SendInvoiceResponse

async get_invoice_info(invoice_id)[исходный код]

Статус выставленного счёта.

Параметры:

invoice_id (str)

Тип результата:

InvoiceInfo

async create_onetime_qr(request)[исходный код]

Одноразовая СБП-ссылка/QR для приёма оплаты.

Параметры:

request (CreateOnetimeQrRequest)

Тип результата:

SbpQrResponse

async create_reusable_qr(request)[исходный код]

Многоразовая СБП-ссылка/QR.

Параметры:

request (CreateReusableQrRequest)

Тип результата:

SbpQrResponse

async get_qr_info(qr_id, *, with_image=False)[исходный код]

Статус СБП-ссылки (опционально с картинкой QR).

Параметры:
Тип результата:

SbpQrResponse

Модели

class tbank.business.models.BusinessModel[исходный код]

Базовые классы: BaseModel

Базовая модель T-API: snake_case в Python, camelCase на проводе.

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.Balance(*, otb=None, authorized=None, pendingPayments=None, pendingRequisitions=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.TransitAccount(*, accountNumber=None)[исходный код]

Базовые классы: BusinessModel

Параметры:

accountNumber (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.Account(*, accountNumber, name, currency, bankBik, accountType, balance=None, transitAccount=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.StatementParams(*, accountNumber, from_, to=None, cursor=None, limit=None, withBalances=None, operationStatus=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.Counterparty(*, account=None, inn=None, kpp=None, name=None, bankName=None, bicRu=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • account (str | None)

  • inn (str | None)

  • kpp (str | None)

  • name (str | None)

  • bankName (str | None)

  • bicRu (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.StatementOperation(*, operationId, operationDate, operationStatus=None, typeOfOperation=None, category=None, operationAmount=None, accountAmount=None, rubleAmount=None, payPurpose=None, payer=None, receiver=None, counterParty=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.StatementBalances(*, balanceBegin=None, balanceEnd=None, credit=None, debit=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.StatementPage(*, balances=None, operations=<factory>, nextCursor=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.BankStatementParams(*, accountNumber, from_=None, till=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • accountNumber (str)

  • from_ (date | None)

  • till (date | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.BankStatementOperation(*, id=None, date=None, amount=None, paymentPurpose=None, payerName=None, payerInn=None, payerKpp=None, recipientName=None, recipientInn=None, recipientKpp=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • id (str | None)

  • date (None)

  • amount (Decimal | None)

  • paymentPurpose (str | None)

  • payerName (str | None)

  • payerInn (str | None)

  • payerKpp (str | None)

  • recipientName (str | None)

  • recipientInn (str | None)

  • recipientKpp (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.BankStatement(*, saldoIn=None, income=None, outcome=None, saldoOut=None, operation=<factory>)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.PaymentFrom(*, accountNumber)[исходный код]

Базовые классы: BusinessModel

Параметры:

accountNumber (str)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.ReceiverRequisites(*, name, inn, accountNumber, bik, kpp=None, bankName=None, corrAccountNumber=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • name (str)

  • inn (str)

  • accountNumber (str)

  • bik (str)

  • kpp (str | None)

  • bankName (str | None)

  • corrAccountNumber (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.ThirdParty(*, inn, kpp, name=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.TaxPaymentParameters(*, payerStatus, kbk, oktmo, evidence, period, docNumber, docDate, thirdParty=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.CreatePaymentRequest(*, id=<factory>, from_, to, purpose, amount, documentNumber=None, executionOrder=None, dueDate=None, uin=None, tax=None, revenueTypeCode=None, meta=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.PaymentStatusResponse(*, status, errorMessage=None, meta=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.DocumentsStatusRequest(*, documentIds)[исходный код]

Базовые классы: BusinessModel

Параметры:

documentIds (List[str])

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.DocumentStatus(*, documentId=None, status=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • documentId (str | None)

  • status (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.DocumentStatusError(*, documentId=None, errorMessage=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • documentId (str | None)

  • errorMessage (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.DocumentsStatusResponse(*, result=<factory>, resultError=<factory>)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.InvoicePayer(*, name=None, inn=None, kpp=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • name (str | None)

  • inn (str | None)

  • kpp (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.InvoiceItem(*, name, price, unit, vat, amount)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • name (str)

  • price (Annotated[Decimal, PlainSerializer(func=~tbank.business.models.<lambda>, return_type=float, when_used=json)])

  • unit (str)

  • vat (InvoiceVat)

  • amount (Annotated[Decimal, PlainSerializer(func=~tbank.business.models.<lambda>, return_type=float, when_used=json)])

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.InvoiceContact(*, email=None)[исходный код]

Базовые классы: BusinessModel

Параметры:

email (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.SendInvoiceRequest(*, invoiceNumber, dueDate=None, invoiceDate=None, accountNumber=None, payer=None, items=None, contacts=None, contactPhone=None, comment=None, customPaymentPurpose=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.SendInvoiceResponse(*, pdfUrl, invoiceId, incomingInvoiceUrl=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • pdfUrl (str)

  • invoiceId (str)

  • incomingInvoiceUrl (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.InvoiceInfo(*, status)[исходный код]

Базовые классы: BusinessModel

Параметры:

status (InvoiceStatus)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.CreateOnetimeQrRequest(*, sum, purpose, ttl, accountNumber=None, vat=None, redirectUrl=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • sum (Annotated[Decimal, PlainSerializer(func=~tbank.business.models.<lambda>, return_type=float, when_used=json)])

  • purpose (str)

  • ttl (int)

  • accountNumber (str | None)

  • vat (SbpVat | None)

  • redirectUrl (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.CreateReusableQrRequest(*, accountNumber=None, sum=None, purpose=None, vat=None, redirectUrl=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • accountNumber (str | None)

  • sum (Annotated[Decimal, PlainSerializer(func=~tbank.business.models.<lambda>, return_type=float, when_used=json)] | None)

  • purpose (str | None)

  • vat (SbpVat | None)

  • redirectUrl (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.SbpQrImage(*, content=None, mediaType=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
  • content (str | None)

  • mediaType (str | None)

model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.business.models.SbpQrResponse(*, qrId, paymentUrl, type, status, accountNumber, vat=None, sum=None, sumVat=None, dueDate=None, purpose=None, redirectUrl=None, image=None)[исходный код]

Базовые классы: BusinessModel

Параметры:
model_config = {'alias_generator': <function to_camel>, 'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Перечисления

class tbank.business.enums.AccountType(*values)[исходный код]

Базовые классы: str, Enum

CURRENT = 'Current'
TAX = 'Tax'
TENDER = 'Tender'
OVERNIGHT = 'Overnight'
class tbank.business.enums.OperationStatus(*values)[исходный код]

Базовые классы: str, Enum

ALL = 'All'
AUTHORIZATION = 'Authorization'
TRANSACTION = 'Transaction'
class tbank.business.enums.TypeOfOperation(*values)[исходный код]

Базовые классы: str, Enum

CREDIT = 'Credit'
DEBIT = 'Debit'
class tbank.business.enums.PaymentStatus(*values)[исходный код]

Базовые классы: str, Enum

IN_PROGRESS = 'IN_PROGRESS'
EXECUTED = 'EXECUTED'
FAILED = 'FAILED'
CANCELLED = 'CANCELLED'
class tbank.business.enums.InvoiceStatus(*values)[исходный код]

Базовые классы: str, Enum

DRAFT = 'DRAFT'
SUBMITTED = 'SUBMITTED'
EXECUTED = 'EXECUTED'
class tbank.business.enums.InvoiceVat(*values)[исходный код]

Базовые классы: str, Enum

NONE = 'None'
VAT_0 = '0'
VAT_5 = '5'
VAT_7 = '7'
VAT_10 = '10'
VAT_18 = '18'
VAT_20 = '20'
VAT_22 = '22'
class tbank.business.enums.SbpVat(*values)[исходный код]

Базовые классы: str, Enum

VAT_0 = '0'
VAT_5 = '5'
VAT_7 = '7'
VAT_10 = '10'
VAT_20 = '20'
VAT_22 = '22'
class tbank.business.enums.SbpQrType(*values)[исходный код]

Базовые классы: str, Enum

ONETIME = 'Onetime'
REUSABLE = 'Reusable'
class tbank.business.enums.SbpQrStatus(*values)[исходный код]

Базовые классы: str, Enum

READY = 'Ready'
PAID = 'Paid'
CANCELLED = 'Cancelled'
EXPIRED = 'Expired'
FAILED = 'Failed'