27
README.md
27
README.md
@@ -4,9 +4,15 @@
|
|||||||
[][1]
|
[][1]
|
||||||
[](https://www.codefactor.io/repository/github/tiagosiebler/bybit-api)
|
[](https://www.codefactor.io/repository/github/tiagosiebler/bybit-api)
|
||||||
|
|
||||||
|
[][1]
|
||||||
|
|
||||||
[1]: https://www.npmjs.com/package/bybit-api
|
[1]: https://www.npmjs.com/package/bybit-api
|
||||||
|
|
||||||
Node.js connector for the Bybit APIs and WebSockets, with TypeScript & browser support.
|
Node.js connector for the Bybit APIs and WebSockets:
|
||||||
|
- TypeScript support (with type declarations for most API requests & responses).
|
||||||
|
- Integration tests with real API calls validating any changes before they reach npm.
|
||||||
|
- Robust WebSocket integration with connection heartbeats & automatic reconnection.
|
||||||
|
- Browser support (via webpack bundle - see "Browser Usage" below).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
`npm install --save bybit-api`
|
`npm install --save bybit-api`
|
||||||
@@ -21,6 +27,7 @@ Check out my related projects:
|
|||||||
- [ftx-api](https://www.npmjs.com/package/ftx-api)
|
- [ftx-api](https://www.npmjs.com/package/ftx-api)
|
||||||
- [bybit-api](https://www.npmjs.com/package/bybit-api)
|
- [bybit-api](https://www.npmjs.com/package/bybit-api)
|
||||||
- [binance](https://www.npmjs.com/package/binance)
|
- [binance](https://www.npmjs.com/package/binance)
|
||||||
|
- [okx-api](https://www.npmjs.com/package/okx-api)
|
||||||
- Try my misc utilities:
|
- Try my misc utilities:
|
||||||
- [orderbooks](https://www.npmjs.com/package/orderbooks)
|
- [orderbooks](https://www.npmjs.com/package/orderbooks)
|
||||||
- Check out my examples:
|
- Check out my examples:
|
||||||
@@ -32,10 +39,22 @@ Most methods accept JS objects. These can be populated using parameters specifie
|
|||||||
- [Bybit API Inverse Futures Documentation](https://bybit-exchange.github.io/docs/inverse_futures/#t-introduction).
|
- [Bybit API Inverse Futures Documentation](https://bybit-exchange.github.io/docs/inverse_futures/#t-introduction).
|
||||||
- [Bybit API Linear Documentation](https://bybit-exchange.github.io/docs/linear/#t-introduction)
|
- [Bybit API Linear Documentation](https://bybit-exchange.github.io/docs/linear/#t-introduction)
|
||||||
|
|
||||||
|
## REST Clients
|
||||||
|
Each REST API category has a dedicated REST client. Here are the REST clients and their API group:
|
||||||
|
| Class | Description |
|
||||||
|
|:-----------------------------------------------------: |:------------------------------: |
|
||||||
|
| [InverseClient](src/inverse-client.ts) | Inverse Perpetual Futures (v2) |
|
||||||
|
| [LinearClient](src/linear-client.ts) | USDT Perpetual Futures (v2) |
|
||||||
|
| [InverseFuturesClient](src/inverse-futures-client.ts) | Inverse Futures (v2) |
|
||||||
|
| [SpotClient](src/spot-client.ts) | Spot Markets |
|
||||||
|
| USDC Options & Perpetual Contracts | Under Development |
|
||||||
|
| Derivatives V3 unified margin | Under Development |
|
||||||
|
|
||||||
## Structure
|
## Structure
|
||||||
This project uses typescript. Resources are stored in 3 key structures:
|
The connector is written in TypeScript. A pure JavaScript version can be built using `npm run build`, which is also the version published to [npm](https://www.npmjs.com/package/bybit-api). This connector is fully compatible with both TypeScript and pure JavaScript projects.
|
||||||
- [src](./src) - the whole connector written in typescript
|
|
||||||
- [lib](./lib) - the javascript version of the project (compiled from typescript). This should not be edited directly, as it will be overwritten with each release.
|
- [src](./src) - the whole connector written in TypeScript
|
||||||
|
- [lib](./lib) - the JavaScript version of the project (built from TypeScript). This should not be edited directly, as it will be overwritten with each release.
|
||||||
- [dist](./dist) - the packed bundle of the project for use in browser environments.
|
- [dist](./dist) - the packed bundle of the project for use in browser environments.
|
||||||
- [examples](./examples) - some implementation examples & demonstrations. Contributions are welcome!
|
- [examples](./examples) - some implementation examples & demonstrations. Contributions are welcome!
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
|
|||||||
})
|
})
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE,
|
ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE,
|
||||||
ret_msg: 'order not exists or too late to cancel',
|
ret_msg: 'Order not exists',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -138,8 +138,8 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
|
|||||||
take_profit: 50000,
|
take_profit: 50000,
|
||||||
})
|
})
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
ret_code: API_ERROR_CODE.POSITION_STATUS_NOT_NORMAL,
|
ret_code: API_ERROR_CODE.POSITION_IDX_NOT_MATCH_POSITION_MODE,
|
||||||
ret_msg: 'position status is not normal',
|
ret_msg: 'position idx not match position mode',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ describe('Private Inverse REST API Endpoints', () => {
|
|||||||
})
|
})
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE,
|
ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE,
|
||||||
ret_msg: 'order not exists or too late to cancel',
|
ret_msg: expect.any(String),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ describe('Private Inverse REST API Endpoints', () => {
|
|||||||
})
|
})
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
ret_code: API_ERROR_CODE.POSITION_IS_CROSS_MARGIN,
|
ret_code: API_ERROR_CODE.POSITION_IS_CROSS_MARGIN,
|
||||||
ret_msg: 'position is in crossMargin',
|
ret_msg: expect.any(String),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user