Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 95 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,102 @@
# Changelog

All notable changes to this project will be documented in this file.
## [0.1.1] — 2026-10-09

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Added
- `AccountService.demoApplyMoney(...)`
- `AccountService.getOptionAssetInfo(...)`
- `AccountService.getPayInfo(...)`
- `AccountService.getTradeInfoForAnalysis(...)`
- `AlphaService.getLpOrderList(...)`
- `AlphaService.getLpPayTokenList(...)`
- `AlphaService.getLpPayTokenPrice(...)`
- `AlphaService.getLpPoolInfo(...)`
- `AlphaService.getLpPoolList(...)`
- `AlphaService.getLpPositionList(...)`
- `AlphaService.executeLpRedeem(...)`
- `AlphaService.executeLpStake(...)`
- `AlphaService.executePredictionBuy(...)`
- `AlphaService.getPredictionEngineStatus(...)`
- `AlphaService.getPredictionEventDetail(...)`
- `AlphaService.getPredictionOrderBook(...)`
- `AlphaService.getPredictionOrderEstimate(...)`
- `AlphaService.getPredictionOrderList(...)`
- `AlphaService.getPredictionPayTokenList(...)`
- `AlphaService.getPredictionPortfolioSummary(...)`
- `AlphaService.getPredictionPositionHistory(...)`
- `AlphaService.getPredictionPositionList(...)`
- `AlphaService.getPredictionPriceHistory(...)`
- `AlphaService.executePredictionSell(...)`
- `AlphaService.getPredictionSideMarketList(...)`
- `AlphaService.getPredictionGroupStageDetail(...)`
- `AlphaService.getPredictionMatchList(...)`
- `AlphaService.getPredictionTimelineStages(...)`
- `AlphaService.getPredictionTokenPrice(...)`
- `AlphaService.getAssetDetail(...)`
- `AlphaService.getAssetList(...)`
- `AlphaService.getBizTokenDetails(...)`
- `AlphaService.getBizTokenList(...)`
- `AlphaService.getBizTokenPriceList(...)`
- `AlphaService.getOrderList(...)`
- `AlphaService.getPayTokenList(...)`
- `AlphaService.executePurchase(...)`
- `AlphaService.getTradeQuote(...)`
- `AlphaService.executeRedeem(...)`
- `AssetService.getOverview(...)`
- `AssetService.smallAssetQuote(...)`
- `AssetService.smallAssetConvert(...)`
- `AssetService.getSmallAssetConvertOrder(...)`
- `AssetService.getSmallAssetList(...)`
- `AssetService.setDefaultDepositToAccount(...)`
- `AssetService.limitOrderCallback(...)`
- `AssetService.coinConvertLimitQuery(...)`
- `AssetService.getOrderFromOpen(...)`
- `AssetService.getPortfolioMargin(...)`
- `AssetService.getTotalMembersAssets(...)`
- `AssetService.transferSubMemberSave(...)`
- `AssetService.getWithdrawAddresses(...)`
- `AssetService.getVaspList(...)`
- `CryptoLoanService.getFixedAvailableInventory(...)`
- `CryptoLoanService.getFlexibleAvailableInventory(...)`
- `EarnService.listAutoSavings(...)`
- `EarnService.editEarnAutoSavings(...)`
- `LendingService.insLoanAssociationUid(...)`
- `LendingService.insLoanCoinDeltaAmount(...)`
- `LendingService.insLoanDelayLiqStatus(...)`
- `LendingService.insLoanEnsureTokens(...)`
- `LendingService.insLoanEnsureTokensConvert(...)`
- `LendingService.insLoanGetLoanOrder(...)`
- `LendingService.insLoanLtvConvert(...)`
- `LendingService.insLoanProductInfos(...)`
- `LendingService.insLoanRepaidHistory(...)`
- `LendingService.insLoanRepayLoan(...)`
- `MarketService.getNewDeliveryPrice(...)`
- `MarketService.getOptionBaseCoins(...)`
- `PositionService.getSymbolInfo(...)`
- `SpotMarginService.getTradeCoinState(...)`
- `SpotMarginService.queryFixedAvailableInventory(...)`
- `SpotMarginService.accountFixedBorrow(...)`
- `SpotMarginService.queryFixedBorrowContracts(...)`
- `SpotMarginService.queryFixedBorrowOrders(...)`
- `SpotMarginService.queryFixedBorrowMarket(...)`
- `SpotMarginService.renewFixedBorrow(...)`
- `SpotMarginService.getTradeFlexibleAvailableInventory(...)`
- `SpotMarginService.getTradeAutoRepayMode(...)`
- `SpotMarginService.queryBorrowLiability(...)`
- `SpotMarginService.getTradeMaxBorrowable(...)`
- `SpotMarginService.getTradeRepaymentAvailableAmount(...)`
- `SpotMarginService.setAutoRepayMode(...)`
- `SpotMarginService.spotMarginSetLeverage(...)`
- `SpotMarginService.getTradeState(...)`
- `SpotMarginService.spotMarginSwitchMode(...)`
- `UserService.queryReferralCode(...)`

### Fixed
- Align Alpha prediction, LP, and trade request fields and TypeScript types with the documented API contracts.
- Serialize GET array parameters as repeated query keys so Auto Savings sends and signs `coins=BTC&coins=ETH`.
- Correct API documentation links for newly added service methods.

## [Unreleased] — targeting 0.1.0
## [0.1.0] — 2026-07-17

### Added
- `AccountService.batchSetCollateral(...)`
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

Official lightweight TypeScript / JavaScript connector for the [Bybit V5 REST API](https://bybit-exchange.github.io/docs/v5/intro).

`bybit-official-ts-sdk` is a thin, typed wrapper around the Bybit V5 HTTP endpoints. It ships as a single npm package with one service class per API group (`market`, `trade`, `account`, `position`, `asset`, `user`, `affiliate`, `broker`, `crypto-loan`, `rfq`, `spot-margin`, `earn`, `p2p`, `bot`). Its goal is the same as [`pybit`](https://github.com/bybit-exchange/pybit) on the Python side: an easy-to-use, high-performance connector with a small dependency footprint.
`bybit-official-ts-sdk` is a thin, typed wrapper around the Bybit V5 HTTP endpoints. It ships as a single npm package with one service class per API group (`market`, `trade`, `account`, `position`, `asset`, `user`, `affiliate`, `broker`, `crypto-loan`, `institutional-loan`, `alpha`, `rfq`, `spot-margin`, `earn`, `p2p`, `bot`). Its goal is the same as [`pybit`](https://github.com/bybit-exchange/pybit) on the Python side: an easy-to-use, high-performance connector with a small dependency footprint.

The client currently exposes REST endpoints across **14 service modules**, all reachable from a single `BybitClient`.
The client currently exposes REST endpoints across **16 service modules**, all reachable from a single `BybitClient`.

Capabilities in this release:

Expand All @@ -20,7 +20,7 @@ Capabilities in this release:
- Account: wallet balance, margin mode, collateral, fee rate, transaction log
- Assets: deposit / withdraw / internal-transfer / universal-transfer / convert
- Users & sub-accounts, API-key management
- Crypto Loan (flexible + fixed), Earn (Advance / RWA / PWM / Liquidity Mining), Spot Margin
- Crypto Loan (flexible + fixed), Institutional Loan, Alpha, Earn (Advance / RWA / PWM / Liquidity Mining), Spot Margin
- RFQ (block trades), Affiliate, Broker, P2P, Bot (grid / futures-grid / futures-combo / futures-martingale / DCA)
- Typed error hierarchy — network / timeout / rate-limit / auth / parse / API errors
- Rate-limit budget headers surfaced per response
Expand Down Expand Up @@ -286,11 +286,13 @@ client.market // MarketService — public market data (kline, tick
client.trade // TradeService — orders (create / amend / cancel / batch / history)
client.position // PositionService — positions, leverage, TP/SL, move-position
client.account // AccountService — wallet, margin, collateral, fee-rate, transfer log
client.alpha // AlphaService — Alpha trading, prediction markets, liquidity pools
client.asset // AssetService — deposit / withdraw / transfer / convert / coin info
client.user // UserService — sub-accounts, API-key management
client.affiliate // AffiliateService — sub-affiliate lists
client.broker // BrokerService — broker earnings, distributions
client.cryptoLoan // CryptoLoanService — flexible / fixed crypto loans
client.lending // LendingService — institutional lending
client.rfq // RfqService — request-for-quote (block trades)
client.spotMargin // SpotMarginService — UTA spot margin
client.earn // EarnService — earn, liquidity mining, RWA, PWM, hold-to-earn
Expand Down
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bybit-official-ts-sdk",
"version": "0.1.0",
"version": "0.1.1",
"description": "Official Bybit V5 REST API connector for Node.js (TypeScript-first, axios-based).",
"keywords": [
"bybit",
Expand Down Expand Up @@ -57,10 +57,12 @@
"format": "prettier --write \"src/**/*.ts\"",
"smoke": "node scripts/dist-smoke.js",
"prepublishOnly": "npm run build && npm run smoke",
"typecheck:test": "tsc -p tsconfig.test.json",
"pretest": "npm run typecheck:test",
"test": "jest"
},
"dependencies": {
"axios": "^1.7.0"
"axios": "^1.20.0"
},
"devDependencies": {
"typescript": "^5.4.0",
Expand Down
6 changes: 6 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import { type RestClientOptions } from './config.js'
// gen-sdk-js:client-imports:start
import { AccountService } from './rest-api/account.js'
import { AffiliateService } from './rest-api/affiliate.js'
import { AlphaService } from './rest-api/alpha.js'
import { AssetService } from './rest-api/asset.js'
import { BotService } from './rest-api/bot.js'
import { BrokerService } from './rest-api/broker.js'
import { CryptoLoanService } from './rest-api/crypto-loan.js'
import { EarnService } from './rest-api/earn.js'
import { LendingService } from './rest-api/lending.js'
import { MarketService } from './rest-api/market.js'
import { P2pService } from './rest-api/p2p.js'
import { PositionService } from './rest-api/position.js'
Expand All @@ -37,11 +39,13 @@ export class BybitClient {
// gen-sdk-js:client-fields:start
public readonly account: AccountService
public readonly affiliate: AffiliateService
public readonly alpha: AlphaService
public readonly asset: AssetService
public readonly bot: BotService
public readonly broker: BrokerService
public readonly cryptoLoan: CryptoLoanService
public readonly earn: EarnService
public readonly lending: LendingService
public readonly market: MarketService
public readonly p2p: P2pService
public readonly position: PositionService
Expand All @@ -62,11 +66,13 @@ export class BybitClient {
// gen-sdk-js:client-inits:start
this.account = new AccountService(this.http, this.options)
this.affiliate = new AffiliateService(this.http, this.options)
this.alpha = new AlphaService(this.http, this.options)
this.asset = new AssetService(this.http, this.options)
this.bot = new BotService(this.http, this.options)
this.broker = new BrokerService(this.http, this.options)
this.cryptoLoan = new CryptoLoanService(this.http, this.options)
this.earn = new EarnService(this.http, this.options)
this.lending = new LendingService(this.http, this.options)
this.market = new MarketService(this.http, this.options)
this.p2p = new P2pService(this.http, this.options)
this.position = new PositionService(this.http, this.options)
Expand Down
6 changes: 5 additions & 1 deletion src/http/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ function serializeQuery(params: Record<string, unknown> | undefined): string {
const entries: [string, string][] = []
for (const [k, v] of Object.entries(params)) {
if (!isNotNull(v)) continue
entries.push([k, typeof v === 'object' ? JSON.stringify(v) : String(v)])
const values = Array.isArray(v) ? v : [v]
for (const value of values) {
if (!isNotNull(value)) continue
entries.push([k, typeof value === 'object' ? JSON.stringify(value) : String(value)])
}
}
entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
return new URLSearchParams(entries).toString()
Expand Down
61 changes: 61 additions & 0 deletions src/rest-api/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,65 @@ export class AccountService {
signed: true,
})
}

/**
* Apply demo funds
* @see https://bybit-exchange.github.io/docs/v5/demo
*/
async demoApplyMoney(params: {
adjustType?: number
utaDemoApplyMoney?: Array<Record<string, unknown>>
}): Promise<ApiResponse<unknown>> {
return requestJson(this.http, this.opts, {
method: 'POST',
path: '/v5/account/demo-apply-money',
signed: true,
body: params,
})
}

/**
* Get Option Asset Info
* @see https://bybit-exchange.github.io/docs/v5/account/option-asset-info
*/
async getOptionAssetInfo(): Promise<ApiResponse<unknown>> {
return requestJson(this.http, this.opts, {
method: 'GET',
path: '/v5/account/option-asset-info',
signed: true,
})
}

/**
* Get Pay Info
* @see https://bybit-exchange.github.io/docs/v5/account/pay-info
*/
async getPayInfo(params: {
coin?: string
}): Promise<ApiResponse<unknown>> {
return requestJson(this.http, this.opts, {
method: 'GET',
path: '/v5/account/pay-info',
signed: true,
query: params,
})
}

/**
* Get Trade Info For Analysis
* @see https://bybit-exchange.github.io/docs/v5/account/trade-info-for-analysis
*/
async getTradeInfoForAnalysis(params: {
symbol?: string
startTime?: number
endTime?: number
}): Promise<ApiResponse<unknown>> {
return requestJson(this.http, this.opts, {
method: 'GET',
path: '/v5/account/trade-info-for-analysis',
signed: true,
query: params,
})
}

}
Loading
Loading