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 -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:

  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.tar.gz (23.4 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-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mixin_client-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e9086de7704e045d96ce8bd0f53a3a512fb53de9675edb1dead1aa151a22f6d6
MD5 b3f0e198c87b435b7d2e06f6d9f84e81
BLAKE2b-256 cc6a67dcb40b7820ebbcc93ab5ad01162a8a0693aeb0703f506722276c15fc5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mixin_client-0.3.1.tar.gz:

Publisher: release.yml on keying-one/mixin-client-private

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: mixin_client-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mixin_client-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ebf4670f92c7337535dddca79f231d9f55bc9859f7b67cacaf37343e5507771
MD5 c566b7b0a10b017d544cede33d858432
BLAKE2b-256 ee841b68d2abfb6479fa313491ca1a3e5bb5fbc2b88663187cfa22101334293c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mixin_client-0.3.1-py3-none-any.whl:

Publisher: release.yml on keying-one/mixin-client-private

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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