Switch between Production and Sandbox environments
mainThe Tinkoff Invest API provides two environments:
- Production (
INVEST_GRPC_API): For executing real orders on the exchange. - Sandbox (
INVEST_GRPC_API_SANDBOX): For testing API calls and trading hypotheses in an emulator without real market impact.
To switch environments, pass the desired constant to the target parameter when initializing the Client.
from tinkoff.invest import Client
from tinkoff.invest.constants import INVEST_GRPC_API
TOKEN = 'token'
# Using INVEST_GRPC_API for production or INVEST_GRPC_API_SANDBOX for sandbox
with Client(TOKEN, target=INVEST_GRPC_API) as client:
print(client.users.get_accounts())