Skip to main content

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 mixin-client

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:

  1. Direct client methods:
user_info = client.get_me()
client.send_text_message(conversation_id="conversation_id", content="Hello!")
  1. 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")
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mixin_client-0.3.1.post0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mixin_client-0.3.1.post0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file mixin_client-0.3.1.post0.tar.gz.

File metadata

  • Download URL: mixin_client-0.3.1.post0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mixin_client-0.3.1.post0.tar.gz
Algorithm Hash digest
SHA256 8e821830b4cb4cff0f679c0b399d75e6df8b5236f6e1fd90d34b9c4a2e10b0dc
MD5 52ceff771e53d2bfd11ff48f3fac2938
BLAKE2b-256 d4b876fbecc9d2a24360ccee17f9af260a11e8bf72bbe8f8942110617a8072d2

See more details on using hashes here.

File details

Details for the file mixin_client-0.3.1.post0-py3-none-any.whl.

File metadata

File hashes

Hashes for mixin_client-0.3.1.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 8afbe32a95acf40da953bcc8535726d39e46c14793f69190120b9f39fe98ae99
MD5 29ad9023d8726040df02e79a2504306d
BLAKE2b-256 10149106c837fe4ae1ad6dc19905c5388a51ec2541aa8a2c4b6e7264ee03f273

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page