# Python SDK

The official Python SDK wraps the CoinMarketCap Pro API with typed request/response models, automatic retries, and a namespace API grouped by endpoint category.

- **PyPI:** [`coinmarketcap-sdk`](https://pypi.org/project/coinmarketcap-sdk/)
- **GitHub:** [OpenCMC/coinmarketcap-api-python](https://github.com/OpenCMC/coinmarketcap-api-python)
- **Import name:** `coinmarketcap` (package on PyPI is `coinmarketcap-sdk`)
- **Requires:** Python 3.10+

## Get started

1. **Install the package**

   ```bash
   pip install coinmarketcap-sdk
   ```

   Or with `uv` / Poetry:

   ```bash
   uv add coinmarketcap-sdk
   poetry add coinmarketcap-sdk
   ```

1. **Create a client**

   Set your API key from the [Developer Portal](https://pro.coinmarketcap.com/account). For keyless endpoints, use `environment="public"`.

   ```python
   import os
   from coinmarketcap import CoinMarketCap

   cmc = CoinMarketCap(api_key=os.environ["CMC_PRO_API_KEY"])
   ```

1. **Call an endpoint**

   Endpoints are grouped by category on the client instance:

   ```python
   quotes = cmc.cryptocurrency.quotes_latest(id="1,1027")
   listings = cmc.cryptocurrency.listings_latest(limit=10)
   ```

   Async variants use the `async_` prefix:

   ```python
   quotes = await cmc.cryptocurrency.async_quotes_latest(id="1,1027")
   ```

1. **Handle errors**

   The SDK raises typed exceptions for common HTTP failures:

   ```python
   from coinmarketcap import CMCError, RateLimitError, AuthenticationError

   try:
       quotes = cmc.cryptocurrency.quotes_latest(id="1")
   except RateLimitError:
       # 429 — backoff or reduce request rate
       ...
   except AuthenticationError:
       # 401 — check your API key
       ...
   except CMCError as e:
       print(e.status_code, e)
   ```

## Public (keyless) mode

```python
from coinmarketcap import CoinMarketCap

cmc = CoinMarketCap(environment="public")
cmc.cryptocurrency.listings_latest(limit=10)
```

See the [Keyless Public API](/pro-api-reference/keyless-public-api) for available endpoints without a key.

## Next steps

- [Get Started with an API Key](/guides/quick-start) if you have not set up authentication yet
- [Choose an endpoint](/pro-api-reference/endpoint-overview) to find the right API family
- Full README and examples on [GitHub](https://github.com/OpenCMC/coinmarketcap-api-python)
