Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Meridian Python SDK

A Python library for interacting with the Meridian trading platform. This SDK provides tools for trading, managing positions, and accessing market data.

SDK Documentation

For full documentation, visit the documentation site.

View the source code on PyPI.

Installation

Using uv (Recommended)

uv is a fast Python package installer and resolver:

# Install uv if you don't have it
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install the SDK
uv add meridian-exchange

Using pip

pip install meridian-exchange

uvloop installs automatically on CPython for macOS/Linux; Windows and other platforms fall back to asyncio.

Quick Start

The SDK provides two client types:

AsyncRESTClient (Recommended for new applications):

import asyncio
from decimal import Decimal
from meridian import AsyncRESTClient

async def main():
    client = await AsyncRESTClient.create({
        "base_url": "https://api.testnet.meridian.xyz",
        "chain_config": {
            "rpc_url": "https://rpc.testnet.meridian.xyz",
            "private_key": "your_private_key",  # optional - required for trading
        }
    })

    # Get market data
    products = await client.list_products()
    product_ids = [p.id for p in products]
    prices = await client.list_market_prices(product_ids=product_ids)

    # Place an order (requires private key)
    await client.create_order(
        order_type="LIMIT",
        quantity=Decimal("1.0"),
        side=0,  # 0 for buy, 1 for sell
        price=Decimal("100.0"),
        ticker="BTCUSD"
    )

    await client.close()

asyncio.run(main())

RESTClient (Synchronous):

from decimal import Decimal
from meridian import RESTClient

client = RESTClient({
    "base_url": "https://api.testnet.meridian.xyz",
    "chain_config": {
        "rpc_url": "https://rpc.testnet.meridian.xyz",
        "private_key": "your_private_key",  # optional - required for trading
    }
})

# Get market data
products = client.list_products()

# Place an order (requires private key)
order = client.create_order(
    order_type="LIMIT",
    quantity=Decimal("1.0"),
    side=0,
    price=Decimal("100.0"),
    ticker="BTCUSD"
)

Main Features

Market Data

  • List available trading products
  • Get current market prices
  • View market order book
  • Track funding rates

Trading

  • Place market and limit orders
  • Cancel orders
  • View order history
  • Track trades and fills

Account Management

  • Manage subaccounts
  • View positions
  • Track token balances
  • Handle deposits and withdrawals

WebSocket Support

  • Real-time market data and order updates via WebSocket
  • See the WebSocket guide for setup and usage

Configuration

The SDK can be configured with these options:

  • private_key: Your private key for authentication
  • base_url: API endpoint (default: "https://api.testnet.meridian.xyz")
  • timeout: Request timeout in seconds
  • verbose: Enable debug logging
  • rate_limit_headers: Enable rate limit headers

The SDK automatically enables uvloop on supported platforms and transparently falls back to the built-in asyncio loop elsewhere.

Examples

Get Market Data

async def get_market_data():
    client = await AsyncRESTClient.create({"base_url": "https://api.testnet.meridian.xyz"})

    # List all available products
    products = await client.list_products()

    # Get current prices
    all_product_ids = [product.id for product in products]
    prices = await client.list_market_prices(product_ids=all_product_ids)

    # View market liquidity
    products_by_ticker = await client.products_by_ticker()
    btc_product_id = products_by_ticker['BTCUSD'].id
    liquidity = await client.get_market_liquidity(product_id=btc_product_id)

    await client.close()

asyncio.run(get_market_data())

Manage Orders

async def manage_orders():
    config = {
        "base_url": "https://api.testnet.meridian.xyz",
        "chain_config": {
            "rpc_url": "https://rpc.testnet.meridian.xyz",
            "private_key": "your_private_key"
        }
    }
    client = await AsyncRESTClient.create(config)

    # Place a limit order
    order = await client.create_order(
        order_type="LIMIT",
        quantity=Decimal("1.0"),
        side=0,
        price=Decimal("100.0"),
        ticker="BTCUSD"
    )

    # Cancel an order
    subaccounts = await client.subaccounts()
    await client.cancel_orders(
        order_ids=["<uuid of order>"],
        sender=client.chain.address,
        subaccount=subaccounts[0].name
    )

    # View order history
    subaccount_id = subaccounts[0].id
    orders = await client.list_orders(subaccount_id=subaccount_id)

    await client.close()

asyncio.run(manage_orders())

Account Operations

async def account_operations():
    config = {
        "base_url": "https://api.testnet.meridian.xyz",
        "chain_config": {
            "rpc_url": "https://rpc.testnet.meridian.xyz",
            "private_key": "your_private_key"
        }
    }
    client = await AsyncRESTClient.create(config)

    # List subaccounts
    subaccounts = await client.subaccounts()

    # View positions
    positions = await client.list_positions(subaccount_id=subaccounts[0].id)

    # Get token balances
    balances = await client.get_subaccount_balances(subaccount_id=subaccounts[0].id)

    await client.close()

asyncio.run(account_operations())

Meridian Documentation

For full documentation, visit our documentation site.

Support

For issues and questions, please refer to the project's issue tracker or documentation.

Download files

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

Source Distribution

meridian_exchange-0.1.0a5.tar.gz (417.5 kB view details)

Uploaded Source

Built Distribution

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

meridian_exchange-0.1.0a5-py3-none-any.whl (229.5 kB view details)

Uploaded Python 3

File details

Details for the file meridian_exchange-0.1.0a5.tar.gz.

File metadata

  • Download URL: meridian_exchange-0.1.0a5.tar.gz
  • Upload date:
  • Size: 417.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for meridian_exchange-0.1.0a5.tar.gz
Algorithm Hash digest
SHA256 f4248027add188e297a54737e71e7b7e1ea7efbf0eb7872af007dd0a01271e2e
MD5 42849212e3a6c3494bf7ae1a84ee5e36
BLAKE2b-256 767f4239460c91bc0fe0c0320e304002a1a386cccf06a88230cceaabf55dd276

See more details on using hashes here.

File details

Details for the file meridian_exchange-0.1.0a5-py3-none-any.whl.

File metadata

  • Download URL: meridian_exchange-0.1.0a5-py3-none-any.whl
  • Upload date:
  • Size: 229.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for meridian_exchange-0.1.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 316f9e320587f6ac1b5788311d1b204f735e075bea3a230a8ac9ca78e64aba0f
MD5 2799fccaeafffa460271e62c965ca860
BLAKE2b-256 f0ee2e18df8c2947032ab465c127f660c0e7dcf9283f3a142c65a4c33c9297f8

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 Sentry Error logging StatusPage Status page