merx-sdk
Python SDK for the Merx TRON energy exchange.
Installation
pip install merx-sdk
Requires Python 3.11+. No external dependencies (uses stdlib urllib and json).
Quickstart
from merx import MerxClient
client = MerxClient(api_key="sk_live_...")
# Check prices
prices = client.prices.list()
best = client.prices.best("ENERGY")
# Preview cost
preview = client.prices.preview(
resource="ENERGY",
amount=65000,
duration=3600,
)
# Create order
order = client.orders.create(
resource_type="ENERGY",
amount=65000,
duration_sec=3600,
target_address="TYourAddress...",
)
API Reference
Constructor
client = MerxClient(
api_key: str, # Required
base_url: str = "https://merx.exchange", # Optional
)
client.prices
| Method | Returns | Description |
|---|---|---|
list() |
list[ProviderPrice] |
All current prices from all providers |
best(resource, amount=None) |
PriceHistoryEntry |
Cheapest available provider (server-side) |
history(provider=None, resource=None, period="24h") |
list[PriceHistoryEntry] |
Historical price snapshots |
stats() |
PriceStats |
Market statistics |
preview(resource, amount, duration, max_price_sun=None) |
OrderPreview |
Preview order cost |
client.orders
| Method | Returns | Description |
|---|---|---|
create(resource_type, amount, duration_sec, target_address, ...) |
Order |
Place a new order |
list(limit=30, offset=0, status=None) |
tuple[list[Order], int] |
Orders with total count |
get(order_id) |
OrderWithFills |
Order details with fills |
create parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
resource_type |
str |
Yes | "ENERGY" or "BANDWIDTH" |
amount |
int |
Yes | Min 65000 for ENERGY, 300 for BANDWIDTH |
duration_sec |
int |
Yes | Duration in seconds (3600 = 1h, 86400 = 1d) |
target_address |
str |
Yes | TRON address to receive resources |
order_type |
str |
No | "MARKET" (default), "LIMIT", "PERIODIC", "BROADCAST" |
max_price_sun |
int |
No | Maximum price per unit in SUN |
idempotency_key |
str |
No | Prevent duplicate orders |
client.balance
| Method | Returns | Description |
|---|---|---|
get() |
Balance |
TRX, USDT, locked amounts |
deposit_info() |
DepositInfo |
Deposit address and memo |
withdraw(address, amount, currency="TRX", idempotency_key=None) |
Withdrawal |
Withdraw TRX or USDT |
history(period="30D") |
list[HistoryEntry] |
Transaction history |
summary() |
HistorySummary |
Aggregated stats |
client.webhooks
| Method | Returns | Description |
|---|---|---|
create(url, events) |
Webhook |
Register webhook (secret shown once) |
list() |
list[Webhook] |
List all webhooks |
delete(webhook_id) |
bool |
Delete a webhook |
Error Handling
All API errors raise MerxError:
from merx import MerxClient, MerxError
try:
order = client.orders.create(...)
except MerxError as e:
print(e.code, str(e))
Types
All responses are dataclasses: ProviderPrice, PricePoint, PriceHistoryEntry, PriceStats, OrderPreview, PreviewMatch, Balance, DepositInfo, Order, OrderWithFills, Fill, HistoryEntry, HistorySummary, Withdrawal, Webhook.
License
MIT
Metadata
Release files for merx-sdk 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| merx_sdk-2.1.0.tar.gz | 8.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| merx_sdk-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.5 kB
Release files / merx_sdk-2.1.0.tar.gz
| Download URL | merx_sdk-2.1.0.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c139c587557f2e82eaface4cf8628ae4c118e7bb090e284fd9b7716e8ae18f2
|
|
BLAKE2b-256 checksum How to use checksums |
8a577a777a9856cfc70f40a6481ee8f7edbd53b9b43574124603423114b6d12b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / merx_sdk-2.1.0-py3-none-any.whl
| Download URL | merx_sdk-2.1.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27970c9752c0595c3a95b401d5e5692a47bc553d9b869e6bfae889d1378d7cd1
|
|
BLAKE2b-256 checksum How to use checksums |
50180ea55b36a9ee6d9da1824902cb599a5e2ec1f97c8833861c0f05664126e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|