Skip to main content

Production-grade Python SDK for the KryptoExpress API.

Project description

kryptoexpress-sdk

Typed Python SDK for the KryptoExpress API.

Repository: https://github.com/kryptoexpress/kryptoexpress-python

Sources used for this SDK:

  • Swagger/OpenAPI: https://kryptoexpress.pro/api/swagger/documentation.yaml
  • Practical docs: https://raw.githubusercontent.com/kryptoexpress/kryptoexpress/refs/heads/main/api-docs.md

Features

  • Python 3.10+
  • sync and async clients
  • httpx transport
  • pydantic v2 models
  • typed exceptions
  • small, explicit public API
  • client-side domain validation before HTTP calls

Developer Notes

Business rules from the practical API documentation take priority over mechanically mirroring the OpenAPI schema.

This SDK intentionally implements the following domain rules in a centralized validation layer:

  • PAYMENT requires fiatAmount
  • DEPOSIT does not send fiatAmount
  • stablecoins support only paymentType=PAYMENT
  • stablecoins support only exact payment semantics
  • minimum payment amount must be at least the equivalent of 1.00 USD
  • fiat conversion for non-USD minimum checks is delegated to an explicit converter abstraction

Where the OpenAPI spec and practical docs differ, the SDK prefers the safer business rule.

Installation

pip install kryptoexpress-sdk

Quickstart

from kryptoexpress import KryptoExpressClient
from kryptoexpress.models.common import CryptoCurrency, FiatCurrency
from kryptoexpress.models.payments import PaymentCreateRequest

client = KryptoExpressClient(api_key="your-api-key")

payment = client.payments.create(
    PaymentCreateRequest.for_payment(
        crypto_currency=CryptoCurrency.BTC,
        fiat_currency=FiatCurrency.USD,
        fiat_amount=12.34,
        callback_url="https://example.com/callback",
    )
)

payment_shortcut = client.payments.create_payment(
    crypto_currency=CryptoCurrency.BTC,
    fiat_currency=FiatCurrency.USD,
    fiat_amount=12.34,
    callback_url="https://example.com/callback",
)

wallet = client.wallet.get()
prices = client.currencies.get_prices(
    crypto_currencies=[CryptoCurrency.BTC, CryptoCurrency.ETH],
    fiat_currency=FiatCurrency.USD,
)
fiat = client.fiat.list()
client.close()

Public API

from kryptoexpress import AsyncKryptoExpressClient, KryptoExpressClient

Available resource methods:

  • client.payments.create(...)
  • client.payments.create_payment(...)
  • client.payments.create_deposit(...)
  • client.payments.get_by_hash(...)
  • client.wallet.get()
  • client.wallet.withdraw(...)
  • client.wallet.calculate(...)
  • client.wallet.withdraw_all(...)
  • client.wallet.withdraw_single(...)
  • client.wallet.calculate_all(...)
  • client.wallet.calculate_single(...)
  • client.currencies.list_all()
  • client.currencies.list_native()
  • client.currencies.list_stable()
  • client.currencies.get_prices(...)
  • client.fiat.list()

Configuration

Both clients support:

  • api_key
  • base_url
  • timeout
  • max_retries
  • minimum_amount_policy
  • fiat_converter for sync clients
  • async_fiat_converter for async clients

Authentication is sent via the X-Api-Key header.

Payment Types

PAYMENT

  • requires fiatAmount
  • the server converts fiat amount into expected cryptoAmount
  • supports exact payment
  • supports overpayment
  • supports split or aggregated partial payment

DEPOSIT

  • does not send fiatAmount
  • accepts the first incoming on-chain transaction to the generated address
  • determines fiat value after funds arrive
  • should be used when the exact incoming crypto amount is not known ahead of time

Example:

deposit = client.payments.create(
    PaymentCreateRequest.for_deposit(
        crypto_currency=CryptoCurrency.BTC,
        fiat_currency=FiatCurrency.USD,
        callback_url="https://example.com/callback",
    )
)

deposit_shortcut = client.payments.create_deposit(
    crypto_currency=CryptoCurrency.BTC,
    fiat_currency=FiatCurrency.USD,
    callback_url="https://example.com/callback",
)

For DEPOSIT, fiatAmount and cryptoAmount may remain None until funds arrive.

Stablecoin Rules

Supported stablecoins in the practical docs:

  • USDT_ERC20
  • USDC_ERC20
  • USDT_BEP20
  • USDC_BEP20
  • USDT_SOL
  • USDC_SOL

Restrictions enforced by the SDK before HTTP:

  • stablecoins support only paymentType=PAYMENT
  • stablecoins support only exact payment behavior
  • stablecoins do not support overpayment or split-payment semantics

Example:

stablecoin_payment = client.payments.create(
    PaymentCreateRequest.for_payment(
        crypto_currency=CryptoCurrency.USDT_ERC20,
        fiat_currency=FiatCurrency.USD,
        fiat_amount=15.0,
        callback_url="https://example.com/callback",
    )
)

stablecoin_shortcut = client.payments.create_payment(
    crypto_currency=CryptoCurrency.USDT_ERC20,
    fiat_currency=FiatCurrency.USD,
    fiat_amount=15.0,
    callback_url="https://example.com/callback",
)

Minimum Fiat Amount Policy

KryptoExpress service fee is 0.8%, but not less than 1 USD, so the SDK enforces a minimum payment amount equivalent to 1.00 USD.

  • for USD, fiatAmount must be at least 1.00
  • for other fiat currencies, the default SDK behavior does not enforce a client-side minimum check
  • non-USD payments are forwarded to the API without local threshold conversion
  • if you need stricter non-USD pre-validation, provide your own custom MinimumAmountPolicy

Custom Fiat Converter

If you want to build your own stricter policy, you can still pass a callable or adapter that converts fiat amounts:

from kryptoexpress import KryptoExpressClient
from kryptoexpress.models.common import FiatCurrency


def fiat_converter(amount: float, from_currency: FiatCurrency, to_currency: FiatCurrency) -> float:
    if from_currency is FiatCurrency.USD and to_currency is FiatCurrency.EUR:
        return 0.91
    raise RuntimeError("unsupported conversion")


client = KryptoExpressClient(
    api_key="your-api-key",
    fiat_converter=fiat_converter,
)

Example non-USD payment with default SDK behavior:

payment = client.payments.create(
    PaymentCreateRequest.for_payment(
        crypto_currency=CryptoCurrency.BTC,
        fiat_currency=FiatCurrency.EUR,
        fiat_amount=0.91,
        callback_url="https://example.com/callback",
    )
)

Withdrawals And Dry Runs

Use typed requests for ALL and SINGLE withdrawals:

from kryptoexpress.models.wallet import WithdrawalAllRequest, WithdrawalSingleRequest

dry_run = client.wallet.calculate(
    WithdrawalSingleRequest(
        payment_id=123,
        crypto_currency=CryptoCurrency.BTC,
        to_address="bc1destination",
        only_calculate=False,
    )
)

dry_run_shortcut = client.wallet.calculate_single(
    payment_id=123,
    crypto_currency=CryptoCurrency.BTC,
    to_address="bc1destination",
)

withdraw_all = client.wallet.withdraw(
    WithdrawalAllRequest(
        crypto_currency=CryptoCurrency.BTC,
        to_address="bc1destination",
        only_calculate=False,
    )
)

withdraw_all_shortcut = client.wallet.withdraw_all(
    crypto_currency=CryptoCurrency.BTC,
    to_address="bc1destination",
)

client.wallet.calculate(...) always forces onlyCalculate=true and acts as an explicit dry-run.

Callback Signature Verification

KryptoExpress signs callbacks using:

  • header: X-Signature
  • algorithm: HMAC-SHA512
  • message: compact raw JSON body
  • key: callbackSecret

Helper example:

from kryptoexpress import verify_callback_signature


def handle_callback(raw_body: bytes, x_signature: str) -> bool:
    return verify_callback_signature(
        raw_body=raw_body,
        callback_secret="my_super_secret_1234567890",
        signature=x_signature,
    )

This helper is suitable for FastAPI, Flask, or Django handlers where you already have the raw body and the X-Signature header.

Notes On Spec Differences

The current practical docs clarify several areas where the OpenAPI schema is incomplete:

  • GET /payment is public
  • GET /cryptocurrency/price returns a list in practice
  • native, stable, and all-cryptocurrency lists differ in the practical docs
  • wallet balances may omit or add currency keys relative to the broader enum list

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kryptoexpress_sdk-0.1.2.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kryptoexpress_sdk-0.1.2-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file kryptoexpress_sdk-0.1.2.tar.gz.

File metadata

  • Download URL: kryptoexpress_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kryptoexpress_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7a7b1c4a24f80a6a4998c75c1c7e92c5620dda7b03fb1b3117dc7b4000c02db9
MD5 b2762931c89d3032f9d5f338589d5faa
BLAKE2b-256 907f734267cd8f2b4f342d7e0c093e5c64abe55837d35272266eca622d94982c

See more details on using hashes here.

Provenance

The following attestation bundles were made for kryptoexpress_sdk-0.1.2.tar.gz:

Publisher: publish.yml on kryptoexpress/kryptoexpress-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kryptoexpress_sdk-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for kryptoexpress_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 75c686db8b03b22d8a1f9b77ddeace9126705c502c58dbe1051fbedecb1f9ae5
MD5 6c401e25aa61dce8ea35243d19db5e7b
BLAKE2b-256 8921d5b6a65f325b44869812be0735ec2bb120a83f80c89752ccc3b4a6328121

See more details on using hashes here.

Provenance

The following attestation bundles were made for kryptoexpress_sdk-0.1.2-py3-none-any.whl:

Publisher: publish.yml on kryptoexpress/kryptoexpress-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page