Skip to content

droidsfi/lifi-cli

 
 

Repository files navigation

LI.FI CLI

Note: This CLI provides read-only tools — it does not sign or broadcast transactions. Quote responses include unsigned transactionRequest objects 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 chains

Once published to npm:

npm install -g @lifi/cli
lifi chains

No 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 address

Chain 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 quote

Routes

lifi routes \
  --from 1 --to 42161 \
  --from-token USDC --to-token USDC \
  --amount 1000000000 \
  --order CHEAPEST

Transaction 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 hint

Connections

lifi connections                               # All connections
lifi connections --from-chain 1 --to-chain 42161  # Specific pair

Tools (Bridges & DEXes)

lifi tools                     # List all bridges and DEXes
lifi tools --chain 1           # Filter by chain

Gas

lifi gas                       # Gas prices for all chains
lifi gas 1                     # Detailed gas suggestion for Ethereum

API Key Management

lifi auth show                 # Display masked key
lifi auth test                 # Validate key against the API

Health Check

lifi health                    # Check API connectivity and latency

Output 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 --verbose

Configuration

All configuration is via environment variables. No config files needed.

# LI.FI API key (higher rate limits)
export LIFI_API_KEY=your_key_here

Without 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 --watch

Installation

npm (primary)

npm install -g @lifi/cli

npx (no install)

npx @lifi/cli chains

Development

git clone https://github.com/lifinance/lifi-cli.git
cd lifi-cli
npm install
npm run build
node dist/lifi.cjs --help

Scripts

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

About

CLI for LI.FI API (li.quest)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 100.0%