chore(): cleaning & readme

This commit is contained in:
Tiago Siebler
2022-12-25 12:06:54 +00:00
parent f57f53abaa
commit 9aa254d3f1
5 changed files with 14 additions and 17 deletions

View File

@@ -9,12 +9,12 @@
[1]: https://www.npmjs.com/package/bitget-api
Node.js connector for the Bitget APIs and WebSockets:
- Complete integration with all Bitget APIs.
- 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.
- 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).
## 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:
- [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)
- [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)
Or buy me a coffee using any of these:

View File

@@ -22,10 +22,10 @@ const API_PASS = process.env.API_PASS_COM;
const client = new FuturesClient({
apiKey: API_KEY,
// apiKey: 'apiKeyHere',
apiSecret: API_SECRET,
// apiSecret: 'apiSecretHere',
apiPass: API_PASS,
// apiKey: 'apiKeyHere',
// apiSecret: 'apiSecretHere',
// apiPass: 'apiPassHere',
});

View File

@@ -10,10 +10,10 @@ const API_PASS = process.env.API_PASS_COM;
const client = new SpotClient({
apiKey: API_KEY,
// apiKey: 'apiKeyHere',
apiSecret: API_SECRET,
// apiSecret: 'apiSecretHere',
apiPass: API_PASS,
// apiKey: 'apiKeyHere',
// apiSecret: 'apiSecretHere',
// apiPass: 'apiPassHere',
});

View File

@@ -1,6 +1,6 @@
{
"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.",
"main": "lib/index.js",
"types": "lib/index.d.ts",

View File

@@ -54,12 +54,12 @@ export default abstract class BaseRestClient {
};
this.globalRequestOptions = {
// in ms == 5 minutes by default
/** in ms == 5 minutes by default */
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,
headers: {
'X-CHANNEL-API-CODE': '3tem',
'X-CHANNEL-API-CODE': 'hbnni',
'Content-Type': 'application/json',
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(
method: Method,
@@ -130,11 +130,6 @@ export default abstract class BaseRestClient {
// Dispatch request
return axios(options)
.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 (
typeof response.data?.code === 'string' &&
@@ -157,7 +152,7 @@ export default abstract class BaseRestClient {
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.request) {
throw e.message;
@@ -179,6 +174,7 @@ export default abstract class BaseRestClient {
headers: response.headers,
requestOptions: {
...this.options,
// Prevent credentials from leaking into error messages
apiPass: 'omittedFromError',
apiSecret: 'omittedFromError',
},