Legend API
The Legend API gives you programmatic access to Legend’s DeFi infrastructure. Create accounts, earn yield, transfer assets, and monitor portfolios — all through a simple REST API.What you can do
- Manage accounts — Provision sub-accounts with on-chain smart wallets. Hold assets on your own behalf, run an omnibus account for your users, or let end-users own their own keys.
- Earn yield — Deploy assets into DeFi protocols like Compound, Morpho, and Aave
- Swap assets — Trade tokens via DEX aggregation with best-price routing
- Loop — Open and manage looped long positions on Morpho markets
- Borrow & repay — Access lending protocols with collateral management
- Transfer assets — Move funds between wallets and across networks
- Migrate positions — Move supply positions between protocols atomically
- Re-invest rewards — Auto-reinvest protocol rewards
- Monitor portfolios — View balances, track activities, and poll for real-time updates
How it works
You tell Legend what you want to do and where — Legend figures out the rest. Every plan endpoint takes anetwork parameter for the target network. Legend handles bridging funds across chains, covering gas, and submitting transactions.
You never need to bridge manually or check which chain holds the funds. Just specify the action and the target network — this applies to earn, swap, transfer, and every other action that requires funding. For example, to re-invest rewards, Legend will claim rewards on-chain, swap them for the target asset, bridge them to the target chain, and re-supply to the yield protocol — all from a single plan.
Legend uses a plan-sign-execute model. Your server creates a plan (e.g., “earn 1000 USDC on Compound”), the account’s signer approves it with an EIP-712 signature, and Legend executes the on-chain transactions.
Architecture
Every integration starts with a Prime Account — your organization’s container. Under it, you create sub-accounts, each with its own on-chain smart wallet (Quark Wallet) and signer key.Non-custodial
Legend is non-custodial — we never hold signing keys. Every fund movement requires a cryptographic signature from the sub-account’s signer, and Legend cannot produce these signatures. You can use Legend with your own key provider (Privy, Turnkey, Ledger, etc), or you can use a Legend-managed (non-custodial) signer key provided by Turnkey. In either case, you will be in complete control of the funds and are “in the loop” for all transactions. Each sub-account has a signer, controlled by either you or your end-user. Legend supports two signer types:| Type | Description |
|---|---|
| EOA | Standard Ethereum private key (secp256k1). Can optionally be secured via services like Privy or Ledger. |
| Turnkey P256 | Key managed via Turnkey with email/social recovery. |
Funds on Ethereum are held in Legend’s smart wallet contracts (sometimes referred to as “quark wallets”). Thus, when funding your account, you should fund the smart wallet address, not the EOA address.
Next steps
Quickstart
Go from zero to earning yield in 5 minutes
Authentication
Set up your query key or OAuth login
Agent Integration
Connect AI agents via MCP or CLI
CLI Reference
Install the legend-cli binary
TypeScript SDK
Install the TypeScript client
Python SDK
Install the Python client