mangroveai — Python SDK
The mangroveai package is the official Python client for the MangroveAI platform. It wraps every public REST endpoint with typed methods and handles auth, retries, and pagination.
Install
1.0.2 (check PyPI for latest).
Setup
- Create an account at the Developer Portal.
- Go to Settings → API Keys and generate a key.
- Set it as an environment variable:
Hello world
Service modules
The client exposes these service attributes, each mapping to a domain in the REST API.| Module | Purpose |
|---|---|
client.signals | List, validate, and evaluate trading signals |
client.strategies | CRUD for strategies; manage entry/exit rules |
client.backtesting | Run historical backtests, retrieve results |
client.execution | Real-time strategy evaluation, position state |
client.ai_copilot | Conversational strategy creation |
client.crypto_assets | Asset metadata, OHLCV, market data |
client.on_chain | Smart-money flows, DEX/perp trades, whale activity (Nansen + WhaleAlert) — see On-Chain API |
client.defi | TVL/chain/stablecoins (any plan) + Pro: token unlocks, perp funding, treasuries, ETF flows, lending rates (Pro/Startup/Enterprise, 1k/mo cap) — see DeFi API |
client.social | Topic sentiment, mentions, user influence (X / Twitter) — see Social API |
client.docs | Search the knowledge base from your code |
client.kb | Signal and indicator metadata via the KB server |
Common patterns
Create a strategy and run a backtest
Evaluate a signal on the platform
mangrove-kb instead.
Use the AI copilot
The Copilot is a stateful chat agent backed by OpenAI. Start a conversation, send messages until the agent has enough context, then save the generated strategy as a MangroveAI draft.client.ai_copilot.chat_async(session_id, message) — it returns the raw 202 submission and you poll get_conversation(session_id) until processing_status flips to "complete".
See a runnable end-to-end demo at examples/ai_copilot_quickstart.py.
Query on-chain smart-money activity
client.on_chain covers Mangrove’s full Nansen Pro plan + WhaleAlert Enterprise. Filters and sort orders pass straight through to the upstream provider, so you can use the same vocabulary the Nansen API itself accepts.
examples/on_chain_nansen.py.
Auth options
- API key (recommended for backend code):
client = MangroveAI(api_key="prod_...")or via env. - JWT (for short-lived tokens):
client = MangroveAI(jwt="...").
Source
- PyPI:
mangroveai - License: MIT