Migrating from 0.5.x to 1.0.0
This guide covers the breaking changes introduced in v1.0.0 and how to update your code.
create_invoice() signature change
The asset parameter is no longer the first positional argument and is now
optional. amount is the first positional argument.
Before (0.5.x):
invoice = client.create_invoice(Asset.TON, 1.5)
# or with keyword arguments
invoice = client.create_invoice(asset=Asset.TON, amount=1.5)
After (1.0.0):
invoice = client.create_invoice(1.5, asset=Asset.TON)
# keyword-only style still works, but asset must come after amount
invoice = client.create_invoice(amount=1.5, asset=Asset.TON)
If you were already using asset= and amount= as keyword arguments, the only
change is that asset is now optional (required only for crypto invoices).
Fiat invoices
The signature change enables the new fiat invoice support. To create a fiat
invoice, omit asset and pass currency_type, fiat, and accepted_assets
instead:
invoice = client.create_invoice(
amount=10.00,
currency_type="fiat",
fiat="USD",
accepted_assets="USDT,TON,BTC",
)
ExchangeRate.source is now a str
ExchangeRate.source changed from the Asset enum to a plain str because
the API can return fiat currency codes that are not members of Asset.
Before (0.5.x):
rates = client.get_exchange_rates()
btc_usd = next(r for r in rates if r.source == Asset.BTC and r.target == "USD")
After (1.0.0):
rates = client.get_exchange_rates()
btc_usd = next(r for r in rates if r.source == "BTC" and r.target == "USD")
Validation error messages
Internal validation was generalized to support checks and transfers. If your
code matches on exception messages from create_invoice or get_invoices,
update accordingly:
0.5.x message |
1.0.0 message |
|---|---|
|
|
|
|
|
|
|
|
|
|
New endpoints
These are additive and do not break existing code, but are worth noting:
delete_invoice(invoice_id)create_check(asset, amount, ...)/delete_check(check_id)get_checks(...)withiter_checks()anditer_check_pages()paginationget_transfers(...)withiter_transfers()anditer_transfer_pages()paginationget_stats(start_at, end_at)fiatfilter parameter onget_invoices()
All new endpoints are available on both CryptoBotClient and
AsyncCryptoBotClient.