{"_id":"@_0xboji/aster-connector-ts","_rev":"4-cac8b7329ee6c414637ca4543c1defc0","name":"@_0xboji/aster-connector-ts","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@_0xboji/aster-connector-ts","version":"1.0.0","keywords":["aster","dex","crypto","trading","typescript","sdk","api","futures","blockchain"],"author":{"name":"Aster DEX"},"license":"MIT","_id":"@_0xboji/aster-connector-ts@1.0.0","maintainers":[{"name":"_0xboji","email":"ngochoangpichtran@gmail.com"}],"homepage":"https://github.com/asterdex/aster-connector-ts#readme","bugs":{"url":"https://github.com/asterdex/aster-connector-ts/issues"},"dist":{"shasum":"804642758351d89ca1891853b959d7bfbc5aa20c","tarball":"https://registry.npmjs.org/@_0xboji/aster-connector-ts/-/aster-connector-ts-1.0.0.tgz","fileCount":57,"integrity":"sha512-KmgXICZVf1mjK4s+jm55J2GzDAmK8/UkIFW2j9sH/RPkeQM2vn8kaSfNI28dClWP7jFcBrOEomI2RnjS79lZaQ==","signatures":[{"sig":"MEYCIQDwFOeiJJmuJuNLQrXBY4LznEeNbTCbpMcZkmFbj6bCRQIhALNO/mhxYOTBovior8lJ7NDzAxBZGuIIFDz/AABD/jja","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":423237},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./utils":{"types":"./dist/utils/index.d.ts","import":"./dist/utils/index.mjs","require":"./dist/utils/index.js"},"./transport":{"types":"./dist/transport/index.d.ts","import":"./dist/transport/index.mjs","require":"./dist/transport/index.js"},"./api/market":{"types":"./dist/api/market/index.d.ts","import":"./dist/api/market/index.mjs","require":"./dist/api/market/index.js"},"./api/trading":{"types":"./dist/api/trading/index.d.ts","import":"./dist/api/trading/index.mjs","require":"./dist/api/trading/index.js"}},"gitHead":"02f18e781451fd998efcae31a022d1dcdb04fbc9","scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts","test":"vitest","build":"tsup","format":"prettier --write \"src/**/*.ts\"","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"_0xboji","email":"ngochoangpichtran@gmail.com"},"repository":{"url":"git+https://github.com/asterdex/aster-connector-ts.git","type":"git"},"_npmVersion":"11.3.0","description":"TypeScript SDK for Aster DEX API - Inspired by Hyperliquid SDK architecture","directories":{},"_nodeVersion":"24.1.0","dependencies":{"ws":"^8.18.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.1","eslint":"^8.55.0","vitest":"^1.0.4","prettier":"^3.1.0","@types/ws":"^8.5.10","typescript":"^5.3.3","@types/node":"^20.10.0","@typescript-eslint/parser":"^6.13.0","@typescript-eslint/eslint-plugin":"^6.13.0"},"_npmOperationalInternal":{"tmp":"tmp/aster-connector-ts_1.0.0_1761826973456_0.19952631964389855","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@_0xboji/aster-connector-ts","version":"1.0.1","keywords":["aster","dex","crypto","trading","typescript","sdk","api","futures","blockchain"],"author":{"name":"Aster DEX"},"license":"MIT","_id":"@_0xboji/aster-connector-ts@1.0.1","maintainers":[{"name":"_0xboji","email":"ngochoangpichtran@gmail.com"}],"homepage":"https://github.com/asterdex/aster-connector-ts#readme","bugs":{"url":"https://github.com/asterdex/aster-connector-ts/issues"},"dist":{"shasum":"7f7d334e31f1989e1e9698a9ea4301638a91fb21","tarball":"https://registry.npmjs.org/@_0xboji/aster-connector-ts/-/aster-connector-ts-1.0.1.tgz","fileCount":57,"integrity":"sha512-lh6sSBi9kOJgGTv+OuuidA5SHWnXEs43kfsi2X76rtaiImBnEFnmDjfFP1h1Q1Iw/t+IF9T0ryKXdGPmeD60AA==","signatures":[{"sig":"MEYCIQDWtDKip4Adm4h3jlyDPZusqaI79Gx9n1p0WDnhrAijugIhAIDcJEwLDj9oEFgRYdp+26XkzReHs6kabVAO0NC/ReMK","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":423214},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./utils":{"types":"./dist/utils/index.d.ts","import":"./dist/utils/index.mjs","require":"./dist/utils/index.js"},"./transport":{"types":"./dist/transport/index.d.ts","import":"./dist/transport/index.mjs","require":"./dist/transport/index.js"},"./api/market":{"types":"./dist/api/market/index.d.ts","import":"./dist/api/market/index.mjs","require":"./dist/api/market/index.js"},"./api/trading":{"types":"./dist/api/trading/index.d.ts","import":"./dist/api/trading/index.mjs","require":"./dist/api/trading/index.js"}},"gitHead":"02f18e781451fd998efcae31a022d1dcdb04fbc9","scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts","test":"vitest","build":"tsup","format":"prettier --write \"src/**/*.ts\"","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"_0xboji","email":"ngochoangpichtran@gmail.com"},"repository":{"url":"git+https://github.com/asterdex/aster-connector-ts.git","type":"git"},"_npmVersion":"11.3.0","description":"TypeScript SDK for Aster DEX API","directories":{},"_nodeVersion":"24.1.0","dependencies":{"ws":"^8.18.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.1","eslint":"^8.55.0","vitest":"^1.0.4","prettier":"^3.1.0","@types/ws":"^8.5.10","typescript":"^5.3.3","@types/node":"^20.10.0","@typescript-eslint/parser":"^6.13.0","@typescript-eslint/eslint-plugin":"^6.13.0"},"_npmOperationalInternal":{"tmp":"tmp/aster-connector-ts_1.0.1_1761827097492_0.48223747851948895","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@_0xboji/aster-connector-ts","version":"1.0.2","keywords":["aster","dex","crypto","trading","typescript","sdk","api","futures","blockchain"],"author":{"name":"Aster DEX"},"license":"MIT","_id":"@_0xboji/aster-connector-ts@1.0.2","maintainers":[{"name":"_0xboji","email":"ngochoangpichtran@gmail.com"}],"homepage":"https://github.com/asterdex/aster-connector-ts#readme","bugs":{"url":"https://github.com/asterdex/aster-connector-ts/issues"},"dist":{"shasum":"070fcacfaa0c2dbf28b7e58b851b3cf6a21c84c3","tarball":"https://registry.npmjs.org/@_0xboji/aster-connector-ts/-/aster-connector-ts-1.0.2.tgz","fileCount":57,"integrity":"sha512-bxWbF/xAuQqrMnVDIvtkkdI63vNly9dPhsAYdL/Qany4zjPnVFtKlSzBFXADwDJcugc+GDT4dX9S8gWLQGAdsA==","signatures":[{"sig":"MEUCIFzNOUO0e9mRLxcPk/hGqacEMQzoQkFXD6ITcZnLoGVbAiEA+AfcPbkH22coD9WCQMDy9lrlEOHDoMhQo6mJifW83V8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":443642},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./utils":{"types":"./dist/utils/index.d.ts","import":"./dist/utils/index.mjs","require":"./dist/utils/index.js"},"./transport":{"types":"./dist/transport/index.d.ts","import":"./dist/transport/index.mjs","require":"./dist/transport/index.js"},"./api/market":{"types":"./dist/api/market/index.d.ts","import":"./dist/api/market/index.mjs","require":"./dist/api/market/index.js"},"./api/trading":{"types":"./dist/api/trading/index.d.ts","import":"./dist/api/trading/index.mjs","require":"./dist/api/trading/index.js"}},"gitHead":"a793c165ab048bf09115cab5b48a1fcf5320e69c","scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts","test":"vitest","build":"tsup","format":"prettier --write \"src/**/*.ts\"","type-check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"_0xboji","email":"ngochoangpichtran@gmail.com"},"repository":{"url":"git+https://github.com/asterdex/aster-connector-ts.git","type":"git"},"_npmVersion":"11.3.0","description":"TypeScript SDK for Aster DEX API","directories":{},"_nodeVersion":"24.1.0","dependencies":{"ws":"^8.18.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.1","eslint":"^8.55.0","vitest":"^1.0.4","prettier":"^3.1.0","@types/ws":"^8.5.10","typescript":"^5.3.3","@types/node":"^20.10.0","@typescript-eslint/parser":"^6.13.0","@typescript-eslint/eslint-plugin":"^6.13.0"},"_npmOperationalInternal":{"tmp":"tmp/aster-connector-ts_1.0.2_1761827314788_0.44702779891764854","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-10-30T12:22:53.372Z","modified":"2026-01-16T10:42:20.298Z","1.0.0":"2025-10-30T12:22:53.661Z","1.0.1":"2025-10-30T12:24:57.671Z","1.0.2":"2025-10-30T12:28:34.945Z"},"bugs":{"url":"https://github.com/asterdex/aster-connector-ts/issues"},"author":{"name":"Aster DEX"},"license":"MIT","homepage":"https://github.com/asterdex/aster-connector-ts#readme","keywords":["aster","dex","crypto","trading","typescript","sdk","api","futures","blockchain"],"repository":{"url":"git+https://github.com/asterdex/aster-connector-ts.git","type":"git"},"description":"TypeScript SDK for Aster DEX API","maintainers":[{"email":"ngochoangpichtran@gmail.com","name":"cloudpro"}],"readme":"# Aster DEX TypeScript SDK\n\n[![npm version](https://img.shields.io/npm/v/@_0xboji/aster-connector-ts.svg)](https://www.npmjs.com/package/@_0xboji/aster-connector-ts)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue.svg)](https://www.typescriptlang.org/)\n\nA modern TypeScript SDK for the Aster DEX API.\n\n## ✨ Features\n\n- 🖋️ **100% TypeScript** - Full type safety and IntelliSense support\n- 🧪 **Well-tested** - Comprehensive test coverage\n- 📦 **Tree-shakeable** - Import only what you need for minimal bundle size\n- 🔧 **Flexible Architecture** - Multiple API access patterns (OOP & Functional)\n- 🌐 **Cross-Environment** - Works in Node.js, browsers, and edge runtimes\n- 🚀 **Modern** - Built with latest TypeScript and ES2022 features\n- 📚 **Well-documented** - JSDoc annotations and examples\n\n## 📦 Installation\n\n```bash\nnpm install @_0xboji/aster-connector-ts\n```\n\n```bash\nyarn add @_0xboji/aster-connector-ts\n```\n\n```bash\npnpm add @_0xboji/aster-connector-ts\n```\n\n## 🚀 Quick Start\n\n### Market Data (Public API)\n\n```typescript\nimport { HttpTransport, MarketClient } from \"@_0xboji/aster-connector-ts\";\n\nconst transport = new HttpTransport();\nconst client = new MarketClient({ transport });\n\n// Get 24hr ticker\nconst ticker = await client.ticker24hr({ symbol: \"BTCUSDT\" });\nconsole.log(`BTC Price: ${ticker.lastPrice}`);\n\n// Get order book\nconst depth = await client.depth({ symbol: \"BTCUSDT\", limit: 10 });\nconsole.log(`Best Bid: ${depth.bids[0][0]}`);\n\n// Get klines\nconst klines = await client.klines({\n  symbol: \"BTCUSDT\",\n  interval: \"1h\",\n  limit: 24,\n});\n```\n\n### Trading (Authenticated API)\n\n```typescript\nimport { HttpTransport, TradingClient } from \"@_0xboji/aster-connector-ts\";\n\nconst transport = new HttpTransport();\nconst client = new TradingClient({\n  transport,\n  apiKey: \"your-api-key\",\n  secretKey: \"your-secret-key\",\n});\n\n// Get account information\nconst account = await client.account();\nconsole.log(`Balance: ${account.totalWalletBalance}`);\n\n// Place a limit order\nconst order = await client.newOrder({\n  symbol: \"BTCUSDT\",\n  side: \"BUY\",\n  type: \"LIMIT\",\n  timeInForce: \"GTC\",\n  quantity: \"0.001\",\n  price: \"50000\",\n});\nconsole.log(`Order ID: ${order.orderId}`);\n\n// Get open orders\nconst openOrders = await client.getOpenOrders({ symbol: \"BTCUSDT\" });\n\n// Cancel an order\nawait client.cancelOrder({ symbol: \"BTCUSDT\", orderId: order.orderId });\n\n// Create listen key for WebSocket user data stream\nconst { listenKey } = await client.newListenKey();\nconsole.log(`Listen Key: ${listenKey}`);\n\n// Keep-alive listen key (must be called every 30 minutes)\nawait client.renewListenKey();\n\n// Close listen key when done\nawait client.closeListenKey();\n```\n\n### WebSocket Streams\n\n```typescript\nimport { WebSocketTransport } from \"@_0xboji/aster-connector-ts\";\n\nconst ws = new WebSocketTransport({\n  debug: true,\n  reconnect: true,\n});\n\nawait ws.connect();\n\n// Subscribe to ticker updates\nconst tickerSub = await ws.subscribe(\"btcusdt@ticker\", (data) => {\n  console.log(`Price: ${data.c}, 24h Change: ${data.P}%`);\n});\n\n// Subscribe to trade updates\nconst tradeSub = await ws.subscribe(\"btcusdt@trade\", (data) => {\n  console.log(`Trade: ${data.p} @ ${data.q}`);\n});\n\n// Unsubscribe when done\nawait tickerSub.unsubscribe();\nawait tradeSub.unsubscribe();\nws.disconnect();\n```\n\n## 🌲 Tree-shakeable API Functions\n\nFor minimal bundle size in frontend applications, you can import individual API functions:\n\n```typescript\nimport { HttpTransport } from \"@_0xboji/aster-connector-ts\";\nimport { ticker24hr, depth } from \"@_0xboji/aster-connector-ts/api/market\";\nimport { account, newOrder } from \"@_0xboji/aster-connector-ts/api/trading\";\n\nconst transport = new HttpTransport();\n\n// Market data\nconst ticker = await ticker24hr({ transport }, { symbol: \"BTCUSDT\" });\nconst orderBook = await depth({ transport }, { symbol: \"BTCUSDT\", limit: 10 });\n\n// Trading (with credentials)\nconst context = {\n  transport,\n  apiKey: \"your-api-key\",\n  secretKey: \"your-secret-key\",\n};\n\nconst acc = await account(context);\nconst order = await newOrder(context, {\n  symbol: \"BTCUSDT\",\n  side: \"BUY\",\n  type: \"LIMIT\",\n  price: \"50000\",\n  quantity: \"0.001\",\n  timeInForce: \"GTC\",\n});\n```\n\n**Benefits:**\n- ✅ Import only what you need\n- ✅ Smaller bundle size\n- ✅ Better for frontend applications\n- ✅ Same functionality as client classes\n\n## 📖 API Documentation\n\n### Transport Layer\n\n#### HttpTransport\n\n```typescript\nimport { HttpTransport } from \"@_0xboji/aster-connector-ts\";\n\nconst transport = new HttpTransport({\n  baseUrl: \"https://fapi.asterdex.com\", // optional\n  timeout: 10000, // optional (ms)\n  debug: false, // optional\n  headers: {}, // optional custom headers\n});\n```\n\n#### WebSocketTransport\n\n```typescript\nimport { WebSocketTransport } from \"@_0xboji/aster-connector-ts\";\n\nconst ws = new WebSocketTransport({\n  wsUrl: \"wss://fstream.asterdex.com\", // optional\n  debug: false, // optional\n  reconnect: true, // optional\n  reconnectDelay: 5000, // optional (ms)\n  maxReconnectAttempts: 10, // optional\n});\n```\n\n### Client Classes\n\n#### MarketClient (Public API)\n\nMethods:\n- `ping()` - Test connectivity\n- `time()` - Get server time\n- `exchangeInfo()` - Get exchange trading rules\n- `depth(params)` - Get order book\n- `trades(params)` - Get recent trades\n- `historicalTrades(params)` - Get historical trades\n- `aggTrades(params)` - Get aggregate trades\n- `klines(params)` - Get candlestick data\n- `indexPriceKlines(params)` - Get index price klines\n- `markPriceKlines(params)` - Get mark price klines\n- `markPrice(params)` - Get mark price and funding rate\n- `fundingRate(params)` - Get funding rate history\n- `ticker24hr(params)` - Get 24hr ticker statistics\n- `tickerPrice(params)` - Get symbol price\n- `bookTicker(params)` - Get best bid/ask\n\n#### TradingClient (Authenticated API)\n\n**Order Management:**\n- `newOrder(params)` - Place a new order\n- `newBatchOrder(params)` - Place multiple orders\n- `queryOrder(params)` - Query order status\n- `cancelOrder(params)` - Cancel an order\n- `cancelAllOrders(params)` - Cancel all open orders\n- `cancelBatchOrders(params)` - Cancel multiple orders\n- `countdownCancelAll(params)` - Auto-cancel all orders\n- `getOpenOrders(params)` - Get current open orders\n- `getAllOrders(params)` - Get all orders\n\n**Account & Balance:**\n- `balance()` - Get account balance\n- `account()` - Get account information\n- `getPositionRisk(params)` - Get position information\n- `getAccountTrades(params)` - Get trade history\n- `getIncomeHistory(params)` - Get income history\n\n**Leverage & Margin:**\n- `changeLeverage(params)` - Change leverage\n- `changeMarginType(params)` - Change margin type\n- `modifyIsolatedPositionMargin(params)` - Modify position margin\n- `getPositionMarginHistory(params)` - Get margin history\n- `getLeverageBrackets(params)` - Get leverage brackets\n\n**Risk Management:**\n- `getADLQuantile(params)` - Get ADL quantile estimation\n- `getForceOrders(params)` - Get liquidation orders\n- `getCommissionRate(params)` - Get commission rate\n\n**Position Mode:**\n- `changePositionMode(params)` - Change position mode\n- `getPositionMode()` - Get current position mode\n- `changeMultiAssetMode(params)` - Change multi-asset mode\n- `getMultiAssetMode()` - Get current multi-asset mode\n\n**Listen Key (User Data Stream):**\n- `newListenKey()` - Create listen key for user data stream\n- `renewListenKey()` - Keep-alive user data stream\n- `closeListenKey()` - Close user data stream\n- `getOpenOrder(params)` - Query single open order\n\n## 📝 Examples\n\nCheck out the `/examples` directory for more detailed examples:\n\n- [`market-data.ts`](./examples/market-data.ts) - Fetching public market data\n- [`trading.ts`](./examples/trading.ts) - Placing orders and managing positions\n- [`tree-shakeable.ts`](./examples/tree-shakeable.ts) - Using tree-shakeable functions\n- [`websocket.ts`](./examples/websocket.ts) - Real-time data streaming\n\n## 🏗️ Architecture\n\nThis SDK is inspired by the [Hyperliquid SDK](https://github.com/nktkas/hyperliquid) architecture:\n\n```\naster-connector-ts/\n├── src/\n│   ├── transport/          # Transport layer (HTTP, WebSocket)\n│   ├── clients/            # Client classes (OOP style)\n│   ├── api/                # Tree-shakeable functions\n│   │   ├── market/         # Market data functions\n│   │   └── trading/        # Trading functions\n│   ├── types/              # TypeScript types\n│   │   ├── common.ts       # Common types\n│   │   ├── market.ts       # Market data types\n│   │   └── trading.ts      # Trading types\n│   └── utils/              # Utilities\n│       ├── signature.ts    # HMAC signature generation\n│       ├── formatters.ts   # Data formatters\n│       └── errors.ts       # Error classes\n├── examples/               # Usage examples\n└── tests/                  # Test files\n```\n\n### Design Principles\n\n1. **Transport Pattern** - Pluggable HTTP/WebSocket transports for flexibility\n2. **Multiple API Patterns** - Both OOP (client classes) and functional styles\n3. **Tree-shaking** - Import only what you need\n4. **Type Safety** - Full TypeScript support with comprehensive types\n5. **Error Handling** - Custom error classes for better debugging\n\n## 🔒 Security\n\n- Never commit your API keys to version control\n- Use environment variables for credentials\n- Consider using a `.env` file (add to `.gitignore`)\n- Be careful when testing on mainnet\n\n```typescript\n// Good practice\nconst apiKey = process.env.ASTER_API_KEY;\nconst secretKey = process.env.ASTER_SECRET_KEY;\n```\n\n## 🛠️ Development\n\n```bash\n# Install dependencies\nnpm install\n\n# Build the project\nnpm run build\n\n# Run type checking\nnpm run type-check\n\n# Run linter\nnpm run lint\n\n# Format code\nnpm run format\n\n# Watch mode (development)\nnpm run dev\n```\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- Based on [Aster Go Connector](https://github.com/0xboji/aster-connector-go)\n- Built for the Aster DEX community\n- Thanks to all contributors\n\n## 📞 Support\n\n- GitHub Issues: [Report a bug](https://github.com/asterdex/aster-connector-ts/issues)\n- Documentation: [API Docs](https://github.com/asterdex/api-docs)\n\n## ⚠️ Disclaimer\n\nThis is an unofficial SDK. Use at your own risk. Always test thoroughly before using in production.\n\n---\n\nMade with ❤️ by the Aster DEX community\n","readmeFilename":"README.md"}