No project description provided
Project description
maicoin
A Python package for MaiCoin MAX API.
Usage
Install package:
# uv
uv add maicoin
# pip
pip install maicoin
Create .env file for private API examples:
MAX_API_KEY=
MAX_API_SECRET=
Run example.py:
python example.py
REST API v3
REST v3 support includes the foundation client, authentication helpers, error handling, public/private endpoint wrappers, and typed response models.
Public requests
from maicoin.v3 import Client
client = Client()
markets = client.markets()
ticker = client.ticker("btctwd")
klines = client.kline("btctwd", period=1, limit=30)
Use Client.request(...) for low-level access when a high-level wrapper is not available yet:
from maicoin.v3 import Client
client = Client()
markets = client.request("GET", "/api/v3/markets")
Private requests
Private requests require MAX credentials and are signed with X-MAX-ACCESSKEY, X-MAX-PAYLOAD, and
X-MAX-SIGNATURE headers.
import os
from maicoin.v3 import Client
client = Client(
api_key=os.environ["MAX_API_KEY"],
api_secret=os.environ["MAX_API_SECRET"],
)
accounts = client.accounts()
open_orders = client.open_orders(market="btctwd")
withdrawals = client.withdrawals(currency="btc", limit=10)
Use Client.request(...) for low-level private access when a high-level wrapper is not available:
import os
from maicoin.v3 import Client
client = Client(
api_key=os.environ["MAX_API_KEY"],
api_secret=os.environ["MAX_API_SECRET"],
)
accounts = client.request("GET", "/api/v3/wallet/spot/accounts", auth=True)
[!WARNING] Some private methods create real account actions, including orders, withdrawals, loans, transfers, repayments, and converts. Review parameters carefully before calling state-changing methods.
WebSocket API
Use Stream with one or more subscriptions to receive typed WebSocket responses:
from maicoin.ws import Channel
from maicoin.ws import Response
from maicoin.ws import Stream
from maicoin.ws import Subscription
def handle_response(response: Response) -> None:
print(response.model_dump(exclude_none=True))
stream = Stream()
stream.subscribe(
[
Subscription(channel=Channel.BOOK, market="btcusdt", depth=5),
Subscription(channel=Channel.TICKER, market="btcusdt"),
Subscription(channel=Channel.TRADE, market="btcusdt"),
Subscription(channel=Channel.MARKET_STATUS),
]
)
stream.add_handler(handle_response)
stream.run()
For authenticated private WebSocket channels, create the stream with credentials or use Stream.from_env() with
MAX_API_KEY and MAX_API_SECRET.
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 maicoin-0.2.0.tar.gz.
File metadata
- Download URL: maicoin-0.2.0.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93cc9ca6c5f7da3bc98db05bd3ee9ab27642f0c0947ced6d3678d25fe9537b5c
|
|
| MD5 |
c31e83d0f9da5a85092528d51cf7338b
|
|
| BLAKE2b-256 |
a97e219a558ebbffd4ed06fd2a3198c90177409fe60f38c32bdbc60ed16592ed
|
File details
Details for the file maicoin-0.2.0-py3-none-any.whl.
File metadata
- Download URL: maicoin-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88ffdfe51d6d828b18df2c931f9c23d5842caec2ec5c60cbd0e4b8d761c0dcb2
|
|
| MD5 |
4fddafbd8021ff62022f0d72e2509664
|
|
| BLAKE2b-256 |
e93a352be9b08d908cb48dd72a90fb50921af3fb0208b29e46fb474553483523
|