Python SDK

The Swarm Python SDK (swarm-collection) is a unified suite of client libraries for trading Real World Assets (RWAs) on Swarm's infrastructure. It provides three SDKs — each suited to different trading scenarios — alongside a smart-routing layer that automatically selects the best platform for each trade.

Install: pip install swarm-collection

GitHub: SwarmMarkets/python-swarm-sdks

Examples: SwarmMarkets/python-swarm-sdks-examples

License: Apache 2.0 | Python: 3.8+


The three SDKs

SDKWhat it doesAvailability
Trading SDKUnified interface with smart routing and automatic price optimisation across both platforms24/7
Market Maker SDKDecentralised P2P OTC trading via smart contracts24/7
Cross-Chain Access SDKCentralised stock market trading with real US exchange pricingMarket hours only (14:30–21:00 UTC, Mon–Fri)

Architecture

The SDKs are layered. The Trading SDK orchestrates the two lower-level SDKs; both share common infrastructure for Web3 operations and authentication:

┌──────────────────────────────────────────────────────────────┐
│                       Trading SDK                            │
│   (Smart routing, price comparison, auto-fallback)           │
└───────────────┬──────────────────────────┬───────────────────┘
                │                          │
      ┌─────────▼──────────┐     ┌─────────▼──────────────┐
      │  Market Maker SDK  │     │  Cross-Chain Access SDK │
      │  (P2P OTC, 24/7)   │     │  (Stock market)         │
      └─────────┬──────────┘     └─────────┬───────────────┘
                │                          │
                └──────────────┬───────────┘
                               │
                      ┌────────▼─────────┐
                      │   Shared module  │
                      │  (Web3, Auth...) │
                      └──────────────────┘

You can use any layer independently. If you only need P2P OTC trading, import the Market Maker SDK directly. If you want automatic routing and fallback across both platforms, use the Trading SDK.


Which SDK should I use?

Do you need to CREATE liquidity offers?
├─ YES → Market Maker SDK

Do you only want stock market pricing during market hours?
├─ YES → Cross-Chain Access SDK

Do you want automatic best-price routing with fallback?
└─ YES → Trading SDK ✅ (recommended for most applications)


Installation & prerequisites

pip install swarm-collection

You will need:

  • Python 3.8 or higher
  • A wallet with a private key
  • Gas tokens (MATIC, ETH, etc.) for transaction fees
  • An RPQ API Key — required for Market Maker SDK access (contact the Swarm team)
  • user email — required for Cross-Chain Access SDK

For Cross-Chain Access specifically:

  • KYC verification completed at https://dotc.eth.limo/
  • Awareness of market hours (14:30–21:00 UTC, weekdays only)

Optional environment variable:

export SWARM_COLLECTION_MODE=prod   # defaults to dev


Supported networks

NetworkChain IDMarket MakerCross-Chain Access
Polygon137
Ethereum1
Base8453
Arbitrum42161
Optimism10
BSC56

SDK guides

→ Trading SDK — Smart routing across both platforms

→ Market Maker SDK — Decentralised P2P OTC trading

→ Cross-Chain Access SDK — Stock market integration

Each SDK guide has a companion API Reference with full method signatures, parameters, return types, and exceptions.