@lifi/cli
v0.1.1-alpha.1
Published
CLI for the LI.FI cross-chain bridge & DEX aggregation API
Maintainers
Readme
LI.FI CLI
Note: This CLI provides read-only tools — it does not sign or broadcast transactions. Quote responses include unsigned
transactionRequestobjects that must be signed and submitted externally using your own wallet.
A TypeScript CLI that wraps the LI.FI REST API to give developers, integrators, and internal teams a scriptable, human-readable interface to cross-chain swap infrastructure.
Quickstart
git clone https://github.com/lifinance/lifi-cli.git
cd lifi-cli
npm install && npm run build
node dist/lifi.cjs chainsOnce published to npm:
npm install -g @lifi/cli
lifi chainsNo API key required — works immediately with public rate limits. Add a key for higher throughput.
Commands
Token Information
lifi tokens --chain 1 # List tokens on Ethereum
lifi tokens --chain 1 --min-price 100 # Filter by min USD price
lifi token 1 USDC # Get specific token detail
lifi token 1 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 # By addressChain Information
lifi chains # List all supported chains
lifi chains --type EVM # Filter by chain type
lifi chain 42161 # Get chain detail by ID
lifi chain arbitrum # Get chain detail by name (case-insensitive)Quote & Swap
# With flags
lifi quote \
--from ethereum --to arbitrum \
--from-token USDC --to-token USDC \
--amount 1000000000 \
--from-address 0xd8dA...
# Interactive mode (prompts for missing flags)
lifi quoteRoutes
lifi routes \
--from 1 --to 42161 \
--from-token USDC --to-token USDC \
--amount 1000000000 \
--order CHEAPESTTransaction Status
lifi status 0xabc123... # One-shot status check
lifi status 0xabc123... --watch # Poll until complete/failed
lifi status 0xabc123... --bridge hop # Speed up lookup with bridge hintConnections
lifi connections # All connections
lifi connections --from-chain 1 --to-chain 42161 # Specific pairTools (Bridges & DEXes)
lifi tools # List all bridges and DEXes
lifi tools --chain 1 # Filter by chainGas
lifi gas # Gas prices for all chains
lifi gas 1 # Detailed gas suggestion for EthereumAPI Key Management
lifi auth show # Display masked key
lifi auth test # Validate key against the APIHealth Check
lifi health # Check API connectivity and latencyOutput Modes
| Mode | Trigger | Behaviour |
|------|---------|-----------|
| Human | Default (TTY detected) | Coloured tables, formatted amounts |
| Machine | --json flag or non-TTY pipe | Raw JSON, stable schema, no colour |
# Pipe-friendly — auto-detects non-TTY
lifi chains | jq '.chains[].name'
# Force JSON in terminal
lifi chains --json
# Disable colour
lifi chains --no-color
# Verbose errors with stack traces
lifi quote --from 1 --to 42161 --verboseConfiguration
All configuration is via environment variables. No config files needed.
# LI.FI API key (higher rate limits)
export LIFI_API_KEY=your_key_hereWithout LIFI_API_KEY, the CLI uses public rate limits (200 req/2hr). With a key, you get 200 req/min.
Exit Codes
| Code | Meaning | |------|---------| | 0 | Success | | 1 | General error | | 2 | Invalid arguments / usage | | 3 | Authentication error | | 4 | API error (rate limit, server error) | | 5 | Network error (unreachable) |
Common Chain IDs
| Chain | ID | Native Token | |-------|-----|--------------| | Ethereum | 1 | ETH | | Polygon | 137 | MATIC | | Arbitrum | 42161 | ETH | | Optimism | 10 | ETH | | BSC | 56 | BNB | | Avalanche | 43114 | AVAX | | Base | 8453 | ETH |
Example Workflow: Cross-Chain Swap
# 1. Find chain IDs
lifi chains --type EVM
# 2. Look up token addresses
lifi token 1 USDC
# 3. Get best quote
lifi quote --from 1 --to 8453 --from-token USDC --to-token USDC --amount 1000000000 --from-address 0xYOUR_ADDRESS
# 4. (External) Approve tokens and sign transactionRequest with your wallet
# 5. Track progress
lifi status 0xTX_HASH --watchInstallation
npm (primary)
npm install -g @lifi/clinpx (no install)
npx @lifi/cli chainsDevelopment
git clone https://github.com/lifinance/lifi-cli.git
cd lifi-cli
npm install
npm run build
node dist/lifi.cjs --helpScripts
| Script | Description |
|--------|-------------|
| npm run build | Build with tsup |
| npm run dev | Watch mode |
| npm test | Run tests (vitest) |
| npm run typecheck | Type check (tsc --noEmit) |
License
MIT
