chore(): cleaning & readme
This commit is contained in:
@@ -9,12 +9,12 @@
|
|||||||
|
|
||||||
[1]: https://www.npmjs.com/package/bitget-api
|
[1]: https://www.npmjs.com/package/bitget-api
|
||||||
|
|
||||||
|
|
||||||
Node.js connector for the Bitget APIs and WebSockets:
|
Node.js connector for the Bitget APIs and WebSockets:
|
||||||
- Complete integration with all Bitget APIs.
|
- Complete integration with all Bitget APIs.
|
||||||
- TypeScript support (with type declarations for most API requests & responses).
|
- TypeScript support (with type declarations for most API requests & responses).
|
||||||
- Over 100 integration tests making real API calls & WebSocket connections, validating any changes before they reach npm.
|
- Over 100 integration tests making real API calls & WebSocket connections, validating any changes before they reach npm.
|
||||||
- Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
|
- Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
|
||||||
|
- Officially listed Node.js SDK in [Bitget API docs](https://bitgetlimited.github.io/apidoc/en/spot/#sdk-code-example).
|
||||||
- Browser support (via webpack bundle - see "Browser Usage" below).
|
- Browser support (via webpack bundle - see "Browser Usage" below).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -157,7 +157,8 @@ The bundle can be found in `dist/`. Altough usage should be largely consistent,
|
|||||||
Support my efforts to make algo trading accessible to all - register with my referral links:
|
Support my efforts to make algo trading accessible to all - register with my referral links:
|
||||||
- [Bybit](https://www.bybit.com/en-US/register?affiliate_id=9410&language=en-US&group_id=0&group_type=1)
|
- [Bybit](https://www.bybit.com/en-US/register?affiliate_id=9410&language=en-US&group_id=0&group_type=1)
|
||||||
- [Binance](https://www.binance.com/en/register?ref=20983262)
|
- [Binance](https://www.binance.com/en/register?ref=20983262)
|
||||||
- [Bitget](https://www.bitget.com/join/18504944)
|
- [Bitget](https://partner.bitget.com/bg/ZNM295)
|
||||||
|
- [OKX](https://www.okx.com/join/18504944)
|
||||||
- [FTX](https://ftx.com/referrals#a=ftxapigithub)
|
- [FTX](https://ftx.com/referrals#a=ftxapigithub)
|
||||||
|
|
||||||
Or buy me a coffee using any of these:
|
Or buy me a coffee using any of these:
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ const API_PASS = process.env.API_PASS_COM;
|
|||||||
|
|
||||||
const client = new FuturesClient({
|
const client = new FuturesClient({
|
||||||
apiKey: API_KEY,
|
apiKey: API_KEY,
|
||||||
// apiKey: 'apiKeyHere',
|
|
||||||
apiSecret: API_SECRET,
|
apiSecret: API_SECRET,
|
||||||
// apiSecret: 'apiSecretHere',
|
|
||||||
apiPass: API_PASS,
|
apiPass: API_PASS,
|
||||||
|
// apiKey: 'apiKeyHere',
|
||||||
|
// apiSecret: 'apiSecretHere',
|
||||||
// apiPass: 'apiPassHere',
|
// apiPass: 'apiPassHere',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ const API_PASS = process.env.API_PASS_COM;
|
|||||||
|
|
||||||
const client = new SpotClient({
|
const client = new SpotClient({
|
||||||
apiKey: API_KEY,
|
apiKey: API_KEY,
|
||||||
// apiKey: 'apiKeyHere',
|
|
||||||
apiSecret: API_SECRET,
|
apiSecret: API_SECRET,
|
||||||
// apiSecret: 'apiSecretHere',
|
|
||||||
apiPass: API_PASS,
|
apiPass: API_PASS,
|
||||||
|
// apiKey: 'apiKeyHere',
|
||||||
|
// apiSecret: 'apiSecretHere',
|
||||||
// apiPass: 'apiPassHere',
|
// apiPass: 'apiPassHere',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bitget-api",
|
"name": "bitget-api",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"description": "Node.js connector for Bitget REST APIs and WebSockets, with TypeScript & end-to-end tests.",
|
"description": "Node.js connector for Bitget REST APIs and WebSockets, with TypeScript & end-to-end tests.",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
|||||||
@@ -54,12 +54,12 @@ export default abstract class BaseRestClient {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.globalRequestOptions = {
|
this.globalRequestOptions = {
|
||||||
// in ms == 5 minutes by default
|
/** in ms == 5 minutes by default */
|
||||||
timeout: 1000 * 60 * 5,
|
timeout: 1000 * 60 * 5,
|
||||||
// custom request options based on axios specs - see: https://github.com/axios/axios#request-config
|
/** inject custom rquest options based on axios specs - see axios docs for more guidance on AxiosRequestConfig: https://github.com/axios/axios#request-config */
|
||||||
...networkOptions,
|
...networkOptions,
|
||||||
headers: {
|
headers: {
|
||||||
'X-CHANNEL-API-CODE': '3tem',
|
'X-CHANNEL-API-CODE': 'hbnni',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
locale: 'en-US',
|
locale: 'en-US',
|
||||||
},
|
},
|
||||||
@@ -103,7 +103,7 @@ export default abstract class BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private Make a HTTP request to a specific endpoint. Private endpoints are automatically signed.
|
* @private Make a HTTP request to a specific endpoint. Private endpoint API calls are automatically signed.
|
||||||
*/
|
*/
|
||||||
private async _call(
|
private async _call(
|
||||||
method: Method,
|
method: Method,
|
||||||
@@ -130,11 +130,6 @@ export default abstract class BaseRestClient {
|
|||||||
// Dispatch request
|
// Dispatch request
|
||||||
return axios(options)
|
return axios(options)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// console.log('response: ', response.data);
|
|
||||||
// console.error('res: ', response);
|
|
||||||
// if (response.data && response.data?.code !== API_ERROR_CODE.SUCCESS) {
|
|
||||||
// throw response.data;
|
|
||||||
// }
|
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
if (
|
if (
|
||||||
typeof response.data?.code === 'string' &&
|
typeof response.data?.code === 'string' &&
|
||||||
@@ -157,7 +152,7 @@ export default abstract class BaseRestClient {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Something happened in setting up the request that triggered an Error
|
// Something happened in setting up the request that triggered an error
|
||||||
if (!e.response) {
|
if (!e.response) {
|
||||||
if (!e.request) {
|
if (!e.request) {
|
||||||
throw e.message;
|
throw e.message;
|
||||||
@@ -179,6 +174,7 @@ export default abstract class BaseRestClient {
|
|||||||
headers: response.headers,
|
headers: response.headers,
|
||||||
requestOptions: {
|
requestOptions: {
|
||||||
...this.options,
|
...this.options,
|
||||||
|
// Prevent credentials from leaking into error messages
|
||||||
apiPass: 'omittedFromError',
|
apiPass: 'omittedFromError',
|
||||||
apiSecret: 'omittedFromError',
|
apiSecret: 'omittedFromError',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user