Skip to main content

pystakan

Python-клиент Stakanex API: обмен RUB ↔ USDT, пополнения, выводы, KYC и всё для партнёров — клиенты, работа от их имени и наценка.

pip install pystakan

Python 3.10+. Синхронный Stakan и асинхронный AsyncStakan с одинаковыми методами.

Начало

from stakan import Stakan

stakan = Stakan("stx_ab12cd34_…")      # или переменная окружения STAKAN_API_KEY
print(stakan.account.balances())

quote = stakan.exchange.quote("9000")                 # рубли → USDT
deal = stakan.exchange.create("9000", quote.rate_version)
print(deal.reference, deal.status)

Ключ выпускается в кабинете: Настройки → API (нужна 2FA). Права: read, trade (обмен, пополнение, KYC, клиенты, наценка), withdraw (адреса и вывод).

Партнёрам

Ключ партнёра открывает аккаунты клиентов и работает от их имени — for_client(id) добавляет к каждому запросу X-Client-Id:

client = stakan.partner.clients.create("client@example.com", external_id="u-1842")
as_client = stakan.for_client(client.id)

session = as_client.kyc.start()          # access_token для WebSDK или redirect_url
print(as_client.kyc.status().status)     # pending → submitted → approved

quote = as_client.exchange.quote("1020") # курс уже с вашей наценкой
as_client.exchange.create("1020", quote.rate_version)

entry = as_client.address_book.add("trc20", "TUEZ…", code="123456")  # ваш код 2FA
as_client.withdrawals.create(entry.id, "30")

stakan.partner.set_markup("2")           # наценка для клиентов, до потолка
print(stakan.partner.get().summary.earned)

Найти клиента по своему id — stakan.partner.clients.find("u-1842"), обойти всех — for c in stakan.partner.clients.iter().

Деньги и повторы

  • Суммы — str, int или Decimal. float не принимается: в нём теряются копейки.
  • Обмен, пополнение и вывод получают Idempotency-Key сами (или ваш — idempotency_key=). При сетевом сбое, 429 и 5xx запрос повторяется с тем же ключом — вторая операция не создастся. max_retries=2 по умолчанию.

Ошибки

Каждый отказ API — исключение с code (стабильный код API), message, status и reference (номер операции, если она осталась в истории):

from stakan import RateChanged, Refused, StakanError

try:
    as_client.exchange.create("1020", quote.rate_version)
except RateChanged:
    ...  # курс или наценка сменились — возьмите новую котировку
except Refused as refusal:
    print(refusal.code, refusal.message)   # insufficient_funds, bad_amount, …

AuthError (401), PermissionDenied (403), NotFound (404), Conflict / RateChanged (409), Refused (422), RateLimited (429), ServerError (5xx), ConnectionFailed — ответа не было.

Асинхронно

from stakan import AsyncStakan

async with AsyncStakan() as stakan:
    async for tx in stakan.for_client(client_id).transactions.iter():
        print(tx.reference, tx.kind, tx.status)

Документация API: https://api.stakanex.io/v1/docs. Лицензия MIT.

Metadata

Release files for pystakan 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pystakan 0.1.0
File Size Uploaded Provenance
pystakan-0.1.0.tar.gz 69.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pystakan 0.1.0
File Interpreter ABI Platform
pystakan-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 87.5 kB

Release files / pystakan-0.1.0.tar.gz

Download URL pystakan-0.1.0.tar.gz
Size 69.0 kB
Tags Source
SHA-256 checksum
How to use checksums
28cbe58f50f1a9396e1a1d1eb399139ad4fc9054f70287d21b3c50cb88dfb847
BLAKE2b-256 checksum
How to use checksums
00d964c302f67fc5821bad23008a1e2afbe9279e00dda9e45f6a31b0df4c0e3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.11

Release files / pystakan-0.1.0-py3-none-any.whl

Download URL pystakan-0.1.0-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36502de2877b269eda08c05db53b25e05dd35fb127ca90b8e1d69a32ade01c97
BLAKE2b-256 checksum
How to use checksums
c64dbdbd7fb3a2a131c2a4ec9cf485d651036d998fe6ead023cf650134bdec5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.11

Security for pystakan 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page