{"_id":"@2oolkit/backpack-cli","_rev":"3-f5f8b56f5a36dbe838ef28e5547dd8b7","name":"@2oolkit/backpack-cli","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@2oolkit/backpack-cli","version":"0.1.0","keywords":["backpack","backpack-exchange","exchange","trading","cli","mcp","mcp-server","model-context-protocol","crypto","perpetuals","spot-trading","solana","defi","api-client","ed25519","borrow-lend","order-management","ai-agent","claude","cursor"],"author":{"name":"haeminmoon"},"license":"ISC","_id":"@2oolkit/backpack-cli@0.1.0","maintainers":[{"name":"haeminmoon","email":"mym0846@gmail.com"}],"homepage":"https://github.com/haeminmoon/backpack-cli#readme","bugs":{"url":"https://github.com/haeminmoon/backpack-cli/issues"},"bin":{"backpack":"dist/index.js","backpack-mcp":"dist/mcp.js"},"dist":{"shasum":"a80966f1d00e65832c9251309c55d35843511c34","tarball":"https://registry.npmjs.org/@2oolkit/backpack-cli/-/backpack-cli-0.1.0.tgz","fileCount":6,"integrity":"sha512-Fjco3L68KB9w2TKYH167BqJAwy7K0wdndAyVWNoB9obDhJthMtdFJBMuhWWChUQIo1jPadmLBsgrkm2ELDLrfQ==","signatures":[{"sig":"MEYCIQCVReT6GtFJslrbtdkcC/Jh0szDIftIiQ1reFnyA+lzHwIhAP75zZfaR3TYDeBj7ZwYHcid8ohq91NuZHdCDorlKr9C","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":274975},"main":"dist/index.js","type":"commonjs","engines":{"node":">=20"},"gitHead":"7ae2e2849a54603c0e3180509a603299e27adc35","scripts":{"dev":"ts-node src/index.ts","lint":"tsc --noEmit","test":"vitest run","build":"tsup","test:unit":"vitest run --config vitest.config.ts","test:watch":"vitest","test:coverage":"vitest run --coverage","test:integration":"vitest run --config vitest.config.integration.ts"},"_npmUser":{"name":"haeminmoon","email":"mym0846@gmail.com"},"repository":{"url":"git+https://github.com/haeminmoon/backpack-cli.git","type":"git"},"_npmVersion":"11.4.2","description":"CLI and MCP server for Backpack Exchange — trade spot, perpetuals, borrow/lend, and manage orders from your terminal or AI agent","directories":{},"_nodeVersion":"24.4.1","dependencies":{"zod":"^4.3.6","commander":"^14.0.3","tweetnacl":"^1.0.3","@modelcontextprotocol/sdk":"^1.27.1"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","vitest":"^4.1.0","typescript":"^5.9.3","@types/node":"^25.5.0","@vitest/coverage-v8":"^4.1.0"},"_npmOperationalInternal":{"tmp":"tmp/backpack-cli_0.1.0_1773803957228_0.686720352480048","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@2oolkit/backpack-cli","version":"0.1.1","keywords":["backpack","backpack-exchange","exchange","trading","cli","mcp","mcp-server","model-context-protocol","crypto","perpetuals","spot-trading","solana","defi","api-client","ed25519","borrow-lend","order-management","ai-agent","claude","cursor"],"author":{"name":"haeminmoon"},"license":"ISC","_id":"@2oolkit/backpack-cli@0.1.1","maintainers":[{"name":"haeminmoon","email":"mym0846@gmail.com"}],"homepage":"https://github.com/haeminmoon/backpack-cli#readme","bugs":{"url":"https://github.com/haeminmoon/backpack-cli/issues"},"bin":{"backpack":"dist/index.js","backpack-mcp":"dist/mcp.js"},"dist":{"shasum":"9ed59c9bae23be06898aefb39b9ca81d7a95b8bf","tarball":"https://registry.npmjs.org/@2oolkit/backpack-cli/-/backpack-cli-0.1.1.tgz","fileCount":6,"integrity":"sha512-hNrtaaPeCyxQNABQO0Ar4r6ve5IRzdOBFgfnQSOAqPZfGnUvTvmBqy5DxupRbYtHaAxC6/FN7AUPrgzg2l6IFA==","signatures":[{"sig":"MEYCIQCD4tS2F8b9JoR4FsFfP6Ne5KfxpFjBL2BrHs54dfYUCAIhAN2Xn2jenKcxvDBT6ESOWzkCgYH6Hoel8cni6niWPLJa","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":278061},"main":"dist/index.js","type":"commonjs","engines":{"node":">=20"},"scripts":{"dev":"ts-node src/index.ts","lint":"tsc --noEmit","test":"vitest run","build":"tsup","test:unit":"vitest run --config vitest.config.ts","test:watch":"vitest","test:coverage":"vitest run --coverage","test:integration":"vitest run --config vitest.config.integration.ts"},"_npmUser":{"name":"haeminmoon","email":"mym0846@gmail.com"},"repository":{"url":"git+https://github.com/haeminmoon/backpack-cli.git","type":"git"},"_npmVersion":"11.4.2","description":"CLI and MCP server for Backpack Exchange — trade spot, perpetuals, borrow/lend, and manage orders from your terminal or AI agent","directories":{},"_nodeVersion":"24.4.1","dependencies":{"zod":"^4.3.6","commander":"^14.0.3","tweetnacl":"^1.0.3","@modelcontextprotocol/sdk":"^1.27.1"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","vitest":"^4.1.0","typescript":"^5.9.3","@types/node":"^25.5.0","@vitest/coverage-v8":"^4.1.0"},"_npmOperationalInternal":{"tmp":"tmp/backpack-cli_0.1.1_1782137764755_0.25269988095059914","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@2oolkit/backpack-cli","version":"0.1.2","description":"CLI and MCP server for Backpack Exchange — trade spot, perpetuals, borrow/lend, and manage orders from your terminal or AI agent","keywords":["backpack","backpack-exchange","exchange","trading","cli","mcp","mcp-server","model-context-protocol","crypto","perpetuals","spot-trading","solana","defi","api-client","ed25519","borrow-lend","order-management","ai-agent","claude","cursor"],"homepage":"https://github.com/haeminmoon/backpack-cli#readme","bugs":{"url":"https://github.com/haeminmoon/backpack-cli/issues"},"repository":{"type":"git","url":"git+https://github.com/haeminmoon/backpack-cli.git"},"license":"ISC","author":{"name":"haeminmoon"},"engines":{"node":">=20"},"type":"commonjs","main":"dist/index.js","bin":{"backpack":"dist/index.js","backpack-mcp":"dist/mcp.js"},"scripts":{"build":"tsup","dev":"ts-node src/index.ts","lint":"tsc --noEmit","test":"vitest run","test:watch":"vitest","test:unit":"vitest run --config vitest.config.ts","test:integration":"vitest run --config vitest.config.integration.ts","test:coverage":"vitest run --coverage"},"dependencies":{"@modelcontextprotocol/sdk":"^1.27.1","commander":"^14.0.3","tweetnacl":"^1.0.3","zod":"^4.3.6"},"devDependencies":{"@types/node":"^25.5.0","@vitest/coverage-v8":"^4.1.0","tsup":"^8.5.1","typescript":"^5.9.3","vitest":"^4.1.0"},"_id":"@2oolkit/backpack-cli@0.1.2","_nodeVersion":"24.4.1","_npmVersion":"11.4.2","dist":{"integrity":"sha512-pGVUFIT0HYFMPh4xdPTWcH86Bg+EoOqfDWD2nkEIklZ2ykwi0Ca2Mj5ePCKifFb3safPlsjPjnV+DCfcOulReg==","shasum":"0905ef0f35b72c37d9d3bc85296fc11ff7c1c05d","tarball":"https://registry.npmjs.org/@2oolkit/backpack-cli/-/backpack-cli-0.1.2.tgz","fileCount":6,"unpackedSize":308945,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICHdIg+D2u8MAcrEQn4QkTr8IJMc/8i+UIjjVFgyoab6AiEAu0TAa7rwChfwtLoTmzvT3GkNdjGJbFid+oJy+nuZ/4o="}]},"_npmUser":{"name":"haeminmoon","email":"mym0846@gmail.com"},"directories":{},"maintainers":[{"name":"haeminmoon","email":"mym0846@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/backpack-cli_0.1.2_1782175010490_0.9435251690396329"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-18T03:19:17.133Z","modified":"2026-06-23T00:36:50.771Z","0.1.0":"2026-03-18T03:19:17.383Z","0.1.1":"2026-06-22T14:16:04.878Z","0.1.2":"2026-06-23T00:36:50.629Z"},"bugs":{"url":"https://github.com/haeminmoon/backpack-cli/issues"},"author":{"name":"haeminmoon"},"license":"ISC","homepage":"https://github.com/haeminmoon/backpack-cli#readme","keywords":["backpack","backpack-exchange","exchange","trading","cli","mcp","mcp-server","model-context-protocol","crypto","perpetuals","spot-trading","solana","defi","api-client","ed25519","borrow-lend","order-management","ai-agent","claude","cursor"],"repository":{"type":"git","url":"git+https://github.com/haeminmoon/backpack-cli.git"},"description":"CLI and MCP server for Backpack Exchange — trade spot, perpetuals, borrow/lend, and manage orders from your terminal or AI agent","maintainers":[{"name":"haeminmoon","email":"mym0846@gmail.com"}],"readme":"# backpack-cli\n\nTrade spot and perpetuals on [Backpack Exchange](https://backpack.exchange) from your terminal or AI agent.\n\n**One package, two interfaces:**\n\n| Interface | Command | Use Case |\n|-----------|---------|----------|\n| **CLI** | `backpack` | Terminal trading, scripting, automation |\n| **MCP Server** | `backpack-mcp` | AI agents (Claude, Cursor, Windsurf, etc.) |\n\nSpot, perpetuals, borrow/lend, and full account management.\n\n## Installation\n\n```bash\nnpm install -g @2oolkit/backpack-cli\n```\n\nThis installs both `backpack` (CLI) and `backpack-mcp` (MCP server).\n\n## Prerequisites\n\n- **Node.js** >= 20\n- A **Backpack Exchange** account with API keys\n- Your **API key** and **API secret** (ED25519 key pair from Backpack settings)\n\n---\n\n## CLI Usage\n\n### Quick Start\n\n```bash\n# 1. Set API credentials\nbackpack config set --api-key <your-key> --api-secret <your-secret>\n\n# 2. Check a price (no auth needed)\nbackpack market ticker -s SOL_USDC\n\n# 3. Place a limit buy\nbackpack order create -s SOL_USDC --side Bid --type Limit -q 1 -p 100\n\n# 4. View open orders\nbackpack order list\n```\n\n### Configuration\n\n```bash\n# Set credentials\nbackpack config set --api-key <base64-key> --api-secret <base64-secret>\n\n# View current config (secrets masked)\nbackpack config get\n\n# Clear all credentials\nbackpack config clear\n```\n\nConfig is saved to `~/.backpack-cli/config.json`.\n\n### Command Reference\n\n#### Market Data (no auth required)\n\n```bash\nbackpack market assets                                  # List all assets\nbackpack market list                                    # List all markets\nbackpack market list -t PERP                            # List perpetual markets only\nbackpack market info -s SOL_USDC                        # Market details\nbackpack market ticker -s SOL_USDC                      # Price, volume, 24h change\nbackpack market tickers                                 # All tickers\nbackpack market depth -s SOL_USDC                       # Order book\nbackpack market depth -s SOL_USDC -l 50                 # Order book (50 levels)\nbackpack market klines -s SOL_USDC -i 1h --start <ts>   # Candlestick data (time range)\nbackpack market klines -s SOL_USDC -i 1h --count 2000   # 2000 most recent 1h bars (single request)\nbackpack market klines -s SOL_USDC -i 1h --count 5000 --paginate  # 5000 bars (auto-windowed)\nbackpack market mark-prices                             # Mark prices\nbackpack market open-interest                           # Open interest\nbackpack market funding-rates -s SOL_USDC_PERP          # Historical funding rates\nbackpack market trades -s SOL_USDC                      # Recent trades\nbackpack market trade-history -s SOL_USDC               # Trade history\n```\n\n##### Candles / klines\n\nBackpack's `GET /api/v1/klines` endpoint is **time-range based** (no count/limit\nparam) and returns **at most 2000 bars per request** — wider windows are rejected\nby the server (`Time range between startTime and endTime is too long`).\n\n- **Intervals**: `1s, 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1month`\n- **`--count <n>`**: fetch the N most recent bars without computing timestamps\n  (sets `endTime = now`, `startTime = now - n * intervalSeconds`). For `n <= 2000`\n  this is a single request.\n- **`--paginate`**: to fetch **more than 2000 bars**, add `--paginate`. The CLI\n  windows the time range into consecutive `<= 2000 * intervalSeconds` chunks\n  (next window starts where the previous ended), then dedupes by candle start\n  time and sorts ascending. The result is capped to the requested `--count`.\n- Requesting `--count > 2000` (or a `--start` window wider than 2000 bars)\n  **without** `--paginate` fails fast with guidance instead of leaking a raw\n  server error.\n- `--start`/`--end` (unix seconds) still work for explicit time ranges; combine\n  with `--paginate` for large ranges.\n\n```bash\nbackpack market klines -s SOL_USDC -i 1h --count 2000              # 2000 bars, single request (max)\nbackpack market klines -s SOL_USDC -i 1h --count 5000 --paginate   # 5000 bars via windowing\nbackpack market klines -s SOL_USDC -i 1m --start 1700000000 --end 1700100000  # explicit range\n```\n\n#### System (no auth required)\n\n```bash\nbackpack system status                                  # Exchange status\nbackpack system ping                                    # Connectivity check\nbackpack system time                                    # Server time\nbackpack system wallets                                 # Exchange wallet addresses\n```\n\n#### Orders (auth required)\n\n```bash\n# Place orders\nbackpack order create -s SOL_USDC --side Bid --type Limit -q 1 -p 100       # Limit buy\nbackpack order create -s SOL_USDC --side Ask --type Limit -q 1 -p 200       # Limit sell\nbackpack order create -s SOL_USDC --side Bid --type Market -q 1             # Market buy\nbackpack order create -s SOL_USDC --side Bid --type PostOnly -q 1 -p 100    # Post-only\nbackpack order create -s SOL_USDC --side Ask --type Limit -q 1 -p 200 --reduce-only  # Reduce-only\n\n# Manage orders\nbackpack order list                                     # Open orders\nbackpack order list -s SOL_USDC                         # Open orders for symbol\nbackpack order get --order-id <id>                      # Order details\nbackpack order cancel --order-id <id> -s SOL_USDC       # Cancel one\nbackpack order cancel-all -s SOL_USDC                   # Cancel all for symbol\n\n# History\nbackpack order history                                  # Order history\nbackpack order fills                                    # Fill history\nbackpack order fills -s SOL_USDC --from <ts> --to <ts>  # Fills with filters\n```\n\n**Order create options:**\n\n| Option | Required | Description |\n|--------|----------|-------------|\n| `-s, --symbol <symbol>` | Yes | Market symbol (e.g., `SOL_USDC`) |\n| `--side <side>` | Yes | `Bid` (buy) or `Ask` (sell) |\n| `--type <orderType>` | Yes | `Limit`, `Market`, `PostOnly`, `FillOrKill`, `ImmediateOrCancel` |\n| `-q, --quantity <qty>` | Yes | Order quantity |\n| `-p, --price <price>` | Limit | Limit price |\n| `--tif <timeInForce>` | No | `GTC`, `IOC`, `FOK`, `PostOnly` |\n| `--client-id <id>` | No | Client order ID |\n| `--reduce-only` | No | Reduce only |\n| `--trigger-price <price>` | No | Trigger price (stop/conditional) |\n| `--take-profit-price <price>` | No | Take profit trigger price |\n| `--take-profit-limit-price <price>` | No | Take profit limit price |\n| `--stop-loss-price <price>` | No | Stop loss trigger price |\n| `--stop-loss-limit-price <price>` | No | Stop loss limit price |\n\n#### Positions (auth required)\n\n```bash\nbackpack position list                                  # All open positions\nbackpack position list -s SOL_USDC_PERP                 # Filter by symbol\nbackpack position get -s SOL_USDC_PERP                  # Single position\nbackpack position history                               # Position history\n```\n\n#### Account (auth required)\n\n```bash\nbackpack account info                                   # Account info (fees, limits)\nbackpack account balances                               # Token balances\nbackpack account collateral                             # Collateral info\nbackpack account max-order -s SOL_USDC --side Bid       # Max order quantity\nbackpack account max-withdrawal -s SOL                  # Max withdrawal\nbackpack account max-borrow -s SOL                      # Max borrow\nbackpack account update --auto-lend true                # Update settings\n```\n\n#### Capital (auth required)\n\n```bash\nbackpack capital deposits                               # Deposit history\nbackpack capital deposit-address -s SOL                  # Get deposit address\nbackpack capital withdrawals                            # Withdrawal history\nbackpack capital withdraw -s SOL -q 1 -a <address> -b Solana  # Withdraw\n```\n\n#### Funding\n\n```bash\nbackpack funding rates -s SOL_USDC_PERP                 # Funding rates (public)\nbackpack funding history -s SOL_USDC_PERP               # Payment history (auth)\n```\n\n#### Borrow / Lend\n\n```bash\n# Public\nbackpack borrow markets                                 # Borrow/lend markets\nbackpack borrow markets-history -i 1d                   # Market history\nbackpack borrow apy                                     # Current APY rates\n\n# Authenticated\nbackpack borrow positions                               # Your borrow/lend positions\nbackpack borrow execute -s SOL --side Lend -q 10        # Lend SOL\nbackpack borrow execute -s USDC --side Borrow -q 100    # Borrow USDC\nbackpack borrow history                                 # Borrow/lend history\nbackpack borrow interest-history                        # Interest payments\n```\n\n### Output Formats\n\nAll commands support `-f json` (default) or `-f table`:\n\n```bash\nbackpack market ticker -s SOL_USDC -f table\nbackpack order list -f json | jq '.[].orderId'\n```\n\n---\n\n## MCP Server\n\nThe MCP (Model Context Protocol) server exposes all Backpack Exchange functionality as tools for AI agents. Works with Claude Code, Claude Desktop, Cursor, Windsurf, and any MCP-compatible client.\n\n### Setup for Claude Code\n\n```bash\nclaude mcp add backpack-mcp -- backpack-mcp\n```\n\n### Setup for Claude Desktop / Cursor / Windsurf\n\nAdd to your MCP config file:\n\n```json\n{\n  \"mcpServers\": {\n    \"backpack\": {\n      \"command\": \"backpack-mcp\"\n    }\n  }\n}\n```\n\nOr without global install:\n\n```json\n{\n  \"mcpServers\": {\n    \"backpack\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"-p\", \"@2oolkit/backpack-cli\", \"backpack-mcp\"]\n    }\n  }\n}\n```\n\n### Setting Credentials via Environment Variables\n\nInstead of running `backpack config set`, you can pass API credentials directly through environment variables in your `.mcp.json` config. This is useful when you want per-project credentials or don't want to store keys in a shared config file.\n\n```json\n{\n  \"mcpServers\": {\n    \"backpack\": {\n      \"command\": \"backpack-mcp\",\n      \"env\": {\n        \"BACKPACK_API_KEY\": \"<your-base64-api-key>\",\n        \"BACKPACK_SECRET_KEY\": \"<your-base64-api-secret>\"\n      }\n    }\n  }\n}\n```\n\nWith `npx`:\n\n```json\n{\n  \"mcpServers\": {\n    \"backpack\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"-p\", \"@2oolkit/backpack-cli\", \"backpack-mcp\"],\n      \"env\": {\n        \"BACKPACK_API_KEY\": \"<your-base64-api-key>\",\n        \"BACKPACK_SECRET_KEY\": \"<your-base64-api-secret>\"\n      }\n    }\n  }\n}\n```\n\nEnvironment variables take priority over the config file (`~/.backpack-cli/config.json`). You can also set them in your shell:\n\n```bash\nexport BACKPACK_API_KEY=<your-base64-api-key>\nexport BACKPACK_SECRET_KEY=<your-base64-api-secret>\n```\n\n### Available Tools (46)\n\n| Category | Tools | Auth |\n|----------|-------|------|\n| **Auth** | `auth_config_set`, `auth_config_get`, `auth_config_clear` | — |\n| **Market** | `get_assets`, `get_markets`, `get_market`, `get_ticker`, `get_tickers`, `get_depth`, `get_klines`, `get_mark_prices`, `get_open_interest`, `get_funding_rates`, `get_recent_trades`, `get_trade_history`, `get_system_status`, `get_server_time` | No |\n| **Account** | `get_account`, `update_account`, `get_balances`, `get_collateral`, `get_max_order_quantity`, `get_max_withdrawal_quantity`, `get_max_borrow_quantity` | Yes |\n| **Orders** | `create_order`, `get_order`, `list_open_orders`, `cancel_order`, `cancel_all_orders`, `get_order_history`, `get_fill_history` | Yes |\n| **Positions** | `list_positions`, `get_position`, `get_position_history` | Yes |\n| **Capital** | `get_deposits`, `get_deposit_address`, `get_withdrawals`, `withdraw` | Yes |\n| **Funding** | `get_funding_rates_public`, `get_funding_payment_history` | Yes |\n| **Borrow** | `get_borrow_lend_markets`, `get_borrow_lend_apy`, `get_borrow_lend_positions`, `execute_borrow_lend`, `get_borrow_history`, `get_interest_history` | Yes |\n\n### MCP Prerequisites\n\nBefore using tools that require authentication, set credentials using one of these methods:\n\n1. **Environment variables in `.mcp.json`** (recommended for MCP) — set `BACKPACK_API_KEY` and `BACKPACK_SECRET_KEY` in the `env` field (see above)\n2. **CLI config** — `backpack config set --api-key <key> --api-secret <secret>`\n3. **MCP tool** — use the `auth_config_set` tool from your AI agent\n\n---\n\n## Market Symbols\n\nBackpack uses trading pair symbols:\n\n| Symbol | Description |\n|--------|-------------|\n| `SOL_USDC` | SOL/USDC spot |\n| `BTC_USDC` | BTC/USDC spot |\n| `ETH_USDC` | ETH/USDC spot |\n| `SOL_USDC_PERP` | SOL/USDC perpetual |\n| `BTC_USDC_PERP` | BTC/USDC perpetual |\n\nUse `backpack market list` for the full list of available markets.\n\n## Error Handling\n\nErrors include actionable recovery instructions:\n\n```\nError: API credentials are not configured.\n\nTry: backpack config set --api-key <key> --api-secret <secret>\n```\n\n## Safety\n\n1. **Use `--reduce-only` for exit orders** — prevents accidental position flips\n2. **Check max quantities** — `backpack account max-order` before placing large orders\n3. **Start with small sizes** when testing\n4. **Never expose your API secret** — credentials are masked in output\n\n## Configuration Files\n\n| File | Path | Description |\n|------|------|-------------|\n| Config | `~/.backpack-cli/config.json` | API key and secret |\n\n## Resources\n\n- **Backpack Exchange**: https://backpack.exchange\n- **GitHub**: https://github.com/haeminmoon/backpack-cli\n- **Backpack API Docs**: https://docs.backpack.exchange\n\n## License\n\nISC\n","readmeFilename":"README.md"}