A Python client for Mixin Network
Project description
Mixin Network Python Client
A Python client for interacting with the Mixin Network API.
Installation
pip install -r requirements.txt
Configuration
The client requires a configuration file in JSON format. You can use the example configuration file as a template:
cp examples/keystore.json.example keystore.json
Then edit keystore.json with your Mixin Network credentials:
{
"app_id": "your-app-id",
"session_id": "your-session-id",
"server_public_key": "your-server-public-key",
"session_private_key": "your-session-private-key"
}
Configuration Fields
app_id: Your Mixin Network application ID (UUID format)session_id: Your Mixin Network session ID (UUID format)server_public_key: Mixin Network server public key (64 characters hex string)session_private_key: Your session private key (64 characters hex string)
Usage
from mixin_client import MixinClient, MixinBotConfig
# Load configuration from file
config = MixinBotConfig.from_file("keystore.json")
# Create client instance
client = MixinClient(config)
# Get user profile
user_info = client.get_me()
print(f"User ID: {user_info.data.user_id}")
print(f"Full Name: {user_info.data.full_name}")
# Get user assets
assets = client.get_assets()
for asset in assets.get("data", []):
print(f"Asset: {asset.get('symbol')} - Balance: {asset.get('balance')}")
API Structure
The client provides multiple ways to access the API:
- Direct client methods:
user_info = client.get_me()
client.send_text_message(conversation_id="conversation_id", content="Hello!")
- Using domain-specific API interfaces:
user_info = client.user.get_me()
client.message.send_text_message(conversation_id="conversation_id", content="Hello!")
client.conversation.create_conversation("user_id")
- Using the unified API interface:
user_info = client.api.user.get_me()
client.api.message.send_text_message(conversation_id="conversation_id", content="Hello!")
client.api.conversation.create_conversation("user_id")
Messaging
The client supports message operations including sending messages, retrieving messages, and creating conversations.
# Create a conversation
conversation = client.conversation.create_conversation("user-id")
conversation_id = conversation.get("data", {}).get("conversation_id")
# Send a text message
message = client.message.send_text_message(
conversation_id=conversation_id,
content="Hello from Mixin Python Client!"
)
# Send an image message
message = client.message.send_image_message(
conversation_id=conversation_id,
attachment_id="attachment_id",
mime_type="image/jpeg",
width=1024,
height=768,
size=1024000
)
# Get messages from a conversation
messages = client.message.get_messages(conversation_id, limit=10)
for msg in messages.data:
print(f"[{msg.created_at}] {msg.user_id}: {msg.content}")
# Acknowledge a message
client.message.acknowledge_message(message.data.id)
For a complete example, see examples/message_example.py.
Features
- User profile management
- Asset management
- Transfer functionality
- Messaging and conversation management
- Real-time message handling via WebSocket
- JWT authentication
- Request/response error handling
- Lazy loading of API components
Development
Running Tests
pytest
Code Formatting
black .
Linting
flake8
License
MIT License
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 mixin_client-0.3.0.tar.gz.
File metadata
- Download URL: mixin_client-0.3.0.tar.gz
- Upload date:
- Size: 23.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d0a335821056157a4f09fe89f13d918eb2502b747b3af4802f84f48a0b2ca38
|
|
| MD5 |
315e7567475bcd1e05df7d2082a092d3
|
|
| BLAKE2b-256 |
701578aee9fb6c25d3512df86a41809d189bad40190f7bde46ae5e4180aa757c
|
Provenance
The following attestation bundles were made for mixin_client-0.3.0.tar.gz:
Publisher:
release.yml on keying-one/mixin-client-private
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mixin_client-0.3.0.tar.gz -
Subject digest:
3d0a335821056157a4f09fe89f13d918eb2502b747b3af4802f84f48a0b2ca38 - Sigstore transparency entry: 209402966
- Sigstore integration time:
-
Permalink:
keying-one/mixin-client-private@f617073799f76ee587f4bd6321823f47555924da -
Branch / Tag:
refs/heads/main - Owner: https://github.com/keying-one
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f617073799f76ee587f4bd6321823f47555924da -
Trigger Event:
push
-
Statement type:
File details
Details for the file mixin_client-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mixin_client-0.3.0-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bde7278e89f017317949e935b69a097b6dda19260f57555fb5e28fd0f99cdddf
|
|
| MD5 |
421f2dc8df6ba3249e9a2a1f73353a7d
|
|
| BLAKE2b-256 |
2df2c8de12ef438e62a859567276b5fff324a62de051b988bd698f3d2fbc2277
|
Provenance
The following attestation bundles were made for mixin_client-0.3.0-py3-none-any.whl:
Publisher:
release.yml on keying-one/mixin-client-private
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mixin_client-0.3.0-py3-none-any.whl -
Subject digest:
bde7278e89f017317949e935b69a097b6dda19260f57555fb5e28fd0f99cdddf - Sigstore transparency entry: 209402968
- Sigstore integration time:
-
Permalink:
keying-one/mixin-client-private@f617073799f76ee587f4bd6321823f47555924da -
Branch / Tag:
refs/heads/main - Owner: https://github.com/keying-one
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f617073799f76ee587f4bd6321823f47555924da -
Trigger Event:
push
-
Statement type: