Official Python SDK for the Mintarex Corporate OTC API.
Project description
mintarex
Official Python SDK for the Mintarex Corporate OTC API.
- HMAC-SHA256 request signing (automatic)
- Typed errors per API error code
- RFQ trading, crypto deposits/withdrawals, webhooks, real-time SSE streams
- Webhook signature verification helper
- Built for Python 3.11+ — one runtime dependency (
httpx) - Full type hints (
py.typed, mypy-strict clean)
Installation
pip install mintarex
# or
uv add mintarex
Python 3.11+ required.
Quick start
import os
from mintarex import Mintarex
mx = Mintarex(
api_key=os.environ["MX_KEY"], # mxn_live_... or mxn_test_...
api_secret=os.environ["MX_SECRET"],
)
# Account
balances = mx.account.balances()
print(balances["balances"])
# Request a quote
quote = mx.rfq.quote({
"base": "BTC",
"quote": "USD",
"side": "buy",
"amount": "0.5",
"amount_type": "base",
})
print("quote_id:", quote["quote_id"], "price:", quote["price"])
# Accept — idempotency_key auto-generated if omitted
trade = mx.rfq.accept(quote["quote_id"])
print("filled:", trade)
Features
| Area | Support |
|---|---|
| HMAC-SHA256 request signing | Built-in, auto-generated nonces + timestamps |
| Typed errors | 13 exception classes mapping HTTP status + API error codes |
| Automatic retries | 429 / 503 / network errors (with Retry-After honored) |
| Rate-limit headers | IETF RFC 9331 RateLimit-* (legacy X-RateLimit-* fallback) |
| SSE streaming | mx.streams.prices() / mx.streams.account() with auto-reconnect + watchdog |
| Webhook verification | Constant-time HMAC check + timestamp tolerance |
| Environments | live or sandbox (inferred from key prefix) |
| Type hints | Full py.typed, mypy-strict clean |
Environments
The environment is inferred from the key prefix:
| Key prefix | Environment |
|---|---|
mxn_live_... |
live |
mxn_test_... |
sandbox |
You can also set it explicitly:
mx = Mintarex(api_key=..., api_secret=..., environment="sandbox")
Error handling
All SDK errors inherit from MintarexError.
from mintarex import (
InsufficientBalanceError,
QuoteExpiredError,
RateLimitError,
ValidationError,
)
try:
trade = mx.rfq.accept(quote_id)
except QuoteExpiredError:
quote = mx.rfq.quote({...}) # re-quote
trade = mx.rfq.accept(quote["quote_id"])
except InsufficientBalanceError as e:
print("top up:", e.message)
except RateLimitError as e:
print("retry after ms:", e.retry_after, "remaining:", e.rate_limit.remaining)
except ValidationError as e:
print("bad input:", e.message)
Streaming (SSE)
with mx.streams.prices() as stream:
for msg in stream:
print(msg.event, msg.data)
Reconnect on transient errors is automatic; a watchdog fires if no data
arrives within 2× the heartbeat interval. Call stream.close() to stop.
Webhook verification
from flask import Flask, request
from mintarex import verify_webhook, WebhookSignatureError
app = Flask(__name__)
@app.post("/hook")
def hook():
try:
event = verify_webhook(
body=request.get_data(), # exact raw bytes, NOT parsed JSON
headers=dict(request.headers),
secret=os.environ["MINTAREX_WEBHOOK_SECRET"],
)
except WebhookSignatureError:
return "", 400
if event["event_type"] == "trade.executed":
handle_trade(event["data"])
return "", 204
Configuration
mx = Mintarex(
api_key=...,
api_secret=...,
environment="sandbox", # optional — inferred from key prefix
base_url="https://institutional.mintarex.com/v1", # optional override
stream_base_url="https://institutional.mintarex.com/v1/stream",
timeout=30.0, # per-request timeout (seconds)
max_retries=3, # for 429/503 and network errors
user_agent="my-app/1.0", # appended to the default UA
)
http:// URLs are permitted only for localhost / 127.0.0.1 / ::1
(dev and test scenarios). Public hosts must use HTTPS.
Resources
| Namespace | Methods |
|---|---|
mx.account |
balances(), balance(currency), fees(), limits() |
mx.rfq |
quote(...), accept(quote_id, idempotency_key=...) |
mx.trades |
list(...), get(trade_uuid) |
mx.crypto |
deposit_address(...), deposits(...), withdraw(...), withdrawals(...), get_withdrawal(...), addresses.list/add/remove |
mx.webhooks |
create(...), list(), remove(endpoint_uuid) |
mx.streams |
prices(), account() |
mx.public |
instruments(), networks(...), fees() |
Support
- API Docs: https://developers.mintarex.com
- Issues: https://github.com/mintarex/mintarex-python/issues
- Contact: support@mintarex.com
License
MIT © Mintarex
Project details
Release history Release notifications | RSS feed
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 mintarex-0.0.6.tar.gz.
File metadata
- Download URL: mintarex-0.0.6.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c278d7d6fb62eaf35018d2d50a68fd51c448393410e4217058de4e688fbc871
|
|
| MD5 |
e63c91b245a750783c5e0e34ae2dab41
|
|
| BLAKE2b-256 |
4be615bf193dfbfad1f9e550718bf27385eafed20fe48ade33fdd70fcebe8a24
|
Provenance
The following attestation bundles were made for mintarex-0.0.6.tar.gz:
Publisher:
publish.yml on mintarex/mintarex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mintarex-0.0.6.tar.gz -
Subject digest:
6c278d7d6fb62eaf35018d2d50a68fd51c448393410e4217058de4e688fbc871 - Sigstore transparency entry: 1376433293
- Sigstore integration time:
-
Permalink:
mintarex/mintarex-python@f785b8f2f5d6674ceeeaf10d71dc8f94a29478c5 -
Branch / Tag:
refs/tags/v0.0.6 - Owner: https://github.com/mintarex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f785b8f2f5d6674ceeeaf10d71dc8f94a29478c5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mintarex-0.0.6-py3-none-any.whl.
File metadata
- Download URL: mintarex-0.0.6-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a6395d6102910c85c202a856626e0e15aa64a92bc368304e3fcda4ed6158cf4
|
|
| MD5 |
fdc80438fcee17af407d09b721a8962d
|
|
| BLAKE2b-256 |
e4f1f25641379a845ef11a2727aabed2ad819bf3cf92aa6738e43aa137436cfb
|
Provenance
The following attestation bundles were made for mintarex-0.0.6-py3-none-any.whl:
Publisher:
publish.yml on mintarex/mintarex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mintarex-0.0.6-py3-none-any.whl -
Subject digest:
8a6395d6102910c85c202a856626e0e15aa64a92bc368304e3fcda4ed6158cf4 - Sigstore transparency entry: 1376433308
- Sigstore integration time:
-
Permalink:
mintarex/mintarex-python@f785b8f2f5d6674ceeeaf10d71dc8f94a29478c5 -
Branch / Tag:
refs/tags/v0.0.6 - Owner: https://github.com/mintarex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f785b8f2f5d6674ceeeaf10d71dc8f94a29478c5 -
Trigger Event:
release
-
Statement type: