Skip to main content

Prerequisites

Before installing the CoW Protocol Python SDK, ensure you have the following:
Python Version: Python 3.10 or higher is required
The SDK is tested on Python 3.10, 3.11, and 3.12. We recommend using the latest stable Python version for the best experience.

Installation via pip

The easiest way to install the CoW Protocol Python SDK is via pip:
pip install cowdao-cowpy
It’s recommended to use a virtual environment to manage your project dependencies. You can create one using venv or poetry.

Using Poetry

If you’re using Poetry for dependency management, add the SDK to your project:
poetry add cowdao-cowpy

Core Dependencies

The SDK automatically installs the following key dependencies:
1

Web3 Integration

web3 (version 6.0.0 or higher, below 8.0.0) - For Ethereum and blockchain interactions
2

HTTP Client

httpx (version 0.23.0 or higher, below 1.0.0) - Async HTTP client for API calls
3

Data Validation

pydantic (version 2.7.0 or higher) - Type-safe data models and validation
4

Additional Libraries

  • eth-abi (version 5.1.0 or higher) - Ethereum ABI encoding/decoding
  • eth-typing (version 4.0.0 or higher, below 6.0.0) - Type hints for Ethereum
  • backoff (version 2.2.1 or higher) - Retry logic for API calls
  • aiolimiter (version 1.1.0 or higher) - Rate limiting for async operations

Development Installation

For contributors or developers who want to work with the source code:
git clone https://github.com/cowdao-grants/cow-py.git
cd cow-py

Verify Installation

After installation, verify that the SDK is working correctly:
from cowdao_cowpy.order_book.api import OrderBookApi
from cowdao_cowpy.common.chains import Chain

# Initialize the API client
order_book_api = OrderBookApi()

print("CoW Protocol SDK installed successfully!")
If you encounter import errors, ensure your Python version meets the minimum requirement (3.10+) and all dependencies are properly installed.

Environment Setup

For interacting with the CoW Protocol, you’ll need:
  1. Private Key: An Ethereum wallet private key (for signing transactions)
  2. RPC Endpoint: Access to an Ethereum/Gnosis Chain node (optional, but recommended for production)
Never commit your private keys to version control. Use environment variables or .env files (with .gitignore) to manage sensitive credentials.

Next Steps

Now that you have the SDK installed, continue to the Quickstart guide to learn how to execute your first token swap!

Build docs developers (and LLMs) love