Official Python client library for the Blocky Crypto Exchange API
Project description
Blocky Python SDK
Official Python client library for the Blocky Crypto Exchange API.
Features
- 🔄 Sync & Async Support - Choose between synchronous (requests) or asynchronous (httpx) clients
- 🔒 Type-Safe - Full type annotations for better IDE support
- ⚡ Lightweight - Minimal dependencies
- 📚 Well Documented - Comprehensive docstrings and examples
Installation
# Basic installation (sync client only)
pip install blockypy
# With async support
pip install blockypy[async]
# Full installation (async + dev tools)
pip install blockypy[all]
Quick Start
Synchronous Client
from blocky import Blocky
# Public API (no authentication required)
client = Blocky()
markets = client.get_markets()
print(markets)
# Private API (requires API key)
client = Blocky(api_key="your-api-key")
wallets = client.get_wallets()
print(wallets)
Asynchronous Client
import asyncio
from blocky import AsyncBlocky
async def main():
# Using context manager (recommended)
async with AsyncBlocky(api_key="your-api-key") as client:
markets = await client.get_markets()
wallets = await client.get_wallets()
print(markets, wallets)
asyncio.run(main())
API Reference
Public Endpoints
These endpoints don't require authentication:
# Get all markets
markets = client.get_markets(get_tickers=True)
# Get specific market
market = client.get_market("xno_xbrl")
# Get 24h ticker
ticker = client.get_ticker("xno_xbrl")
# Get recent trades
transactions = client.get_transactions("xno_xbrl", count=100)
# Get orderbook
orderbook = client.get_orderbook("xno_xbrl", depth=50)
# Get OHLCV/candlestick data
ohlcv = client.get_ohlcv("xno_xbrl", timeframe="1H")
Private Endpoints
These endpoints require an API key:
Wallets
# Get all wallets
wallets = client.get_wallets()
# Get specific wallet
wallet = client.get_wallet("xbrl")
# Get wallet with frozen balance
wallet = client.get_wallet("xbrl", get_frozen=True)
Orders
# Create limit order
order = client.create_order(
type_="limit",
market="xno_xbrl",
side="buy",
price="100.00",
quantity="1.5"
)
# Create market order
order = client.create_order(
type_="market",
market="xno_xbrl",
side="buy",
total="100.00" # Amount to spend
)
# Get orders
orders = client.get_orders(limit=50, statuses=["open"])
# Cancel order
client.cancel_order(order_id=123)
# Cancel all orders
client.cancel_orders()
Trades
# Get trade history
trades = client.get_trades(limit=100, markets=["xno_xbrl"])
Transfers
# Transfer between sub-wallets
transfer = client.create_transfer(
instrument="xbrl",
quantity="100",
source_sub_wallet_id=0,
destination_sub_wallet_id=1,
memo="Savings"
)
# Get transfer history
transfers = client.get_transfers()
Deposits & Withdrawals
# Get deposit history
deposits = client.get_deposits(instruments=["xbrl"])
# Get withdrawal history
withdrawals = client.get_withdrawals()
# Get combined history
history = client.get_deposits_and_withdrawals()
Error Handling
The SDK provides custom exceptions for different error types:
from blocky import (
Blocky,
BlockyError,
BlockyAPIError,
BlockyAuthenticationError,
BlockyNetworkError,
BlockyValidationError,
)
try:
client = Blocky(api_key="invalid-key")
client.get_wallets()
except BlockyAuthenticationError as e:
print(f"Auth failed: {e}")
except BlockyAPIError as e:
print(f"API error [{e.status_code}]: {e.message}")
except BlockyNetworkError as e:
print(f"Network error: {e}")
except BlockyValidationError as e:
print(f"Validation error: {e}")
except BlockyError as e:
print(f"General error: {e}")
Configuration
Custom Endpoint
client = Blocky(
api_key="your-api-key",
endpoint="https://custom.blocky.com.br/api/v1"
)
Custom Timeout
client = Blocky(
api_key="your-api-key",
timeout=60.0 # seconds
)
Timeframes
For OHLCV data, the following timeframe strings are supported:
| Timeframe | Description |
|---|---|
1m |
1 minute |
3m |
3 minutes |
5m |
5 minutes |
15m |
15 minutes |
30m |
30 minutes |
1H |
1 hour |
2H |
2 hours |
4H |
4 hours |
6H |
6 hours |
8H |
8 hours |
12H |
12 hours |
1D |
1 day |
3D |
3 days |
1W |
1 week |
1M |
1 month |
License
MIT License - see LICENSE for details.
Links
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blockypy-0.1.0.tar.gz.
File metadata
- Download URL: blockypy-0.1.0.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a7dd55ea0daa2258cef7b8f97ed41e32e343edffbaef927b7a2fc1137c0b882
|
|
| MD5 |
edc96f831ddc72ef0cb487bd6c1ca7fe
|
|
| BLAKE2b-256 |
111e999ef09d5b21aa60bc9efe86efd8f968520dd7fdeed69d54474ee0c8ffc1
|
File details
Details for the file blockypy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: blockypy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d538ea62d7b85f84b053d6f89b7a353b84daa9feb7bb05c065e1478c6c7647ee
|
|
| MD5 |
5f901ab87cf265211e079169397fd507
|
|
| BLAKE2b-256 |
ee5260489a47e7b1aa0aa809cd75ba6c298b56d44808217b0b21e6d8a959b4b4
|