Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coingecko-api-v3

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coingecko-api-v3 - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

30

dist/CoinGeckoClient.js

@@ -30,2 +30,3 @@ "use strict";

timeout: 30000,
autoRetry: true,
};

@@ -55,5 +56,20 @@ this.options = Object.assign(Object.assign({}, this.options), options);

};
const parseJson = (input) => {
try {
return JSON.parse(input);
}
catch (err) {
return input;
}
};
return new Promise((resolve, reject) => {
const req = https_1.default.request(url, options, (res) => {
if (res.statusCode && (res.statusCode < 200 || res.statusCode > 299)) {
if (res.statusCode && res.statusCode === 429) {
resolve({
statusCode: res.statusCode,
data: {
error: 'HTTP 429 - Too many request',
},
headers: res.headers,
});
// reject(new Error(`HTTP status code ${res.statusCode}`));

@@ -65,3 +81,7 @@ }

const resString = Buffer.concat(body).toString();
resolve(resString);
resolve({
statusCode: res.statusCode,
data: parseJson(resString),
headers: res.headers,
});
});

@@ -91,3 +111,7 @@ });

const res = yield this.httpGet(requestUrl); // await this.http.get<T>(requestUrl);
return JSON.parse(res);
if (res.statusCode === 429 && this.options.autoRetry) {
yield new Promise((r) => setTimeout(r, 2000));
return yield this.makeRequest(action, params);
}
return res.data;
});

@@ -94,0 +118,0 @@ }

@@ -534,2 +534,10 @@ import { PLATFORMS } from './Enum';

timeout?: number;
autoRetry?: boolean;
}
export interface HttpResponse<T> {
data: T;
statusCode: number;
headers: {
[x: string]: string | string[];
};
}

9

jest.config.js
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/**/*.test.ts'],
verbose: true,

@@ -9,8 +10,8 @@ silent: false,

global: {
branches: 70,
functions: 80,
lines: 80,
statements: 80,
branches: 65,
functions: 90,
lines: 90,
statements: 90,
},
},
};
{
"name": "coingecko-api-v3",
"version": "0.0.10",
"version": "0.0.11",
"description": "The nodejs api library for accessing coingecko api v3 , develop with typescript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -9,11 +9,9 @@ # coingecko-api-v3

The nodejs api library for accessing coingecko api v3 , develop with typescript with zero dependencies
Official document here
https:/www.coingecko.com/api/documentations/v3
- [Official document here](https:/www.coingecko.com/api/documentations/v3)
API document generated
https:/samuraitruong.github.io/coingecko-api-v3/classes/coingeckoclient.coingeckoclient-1.html
- [API document generated](https:/samuraitruong.github.io/coingecko-api-v3/classes/coingeckoclient.coingeckoclient-1.html)
## Get started

@@ -30,2 +28,3 @@

timeout: 10000,
autoRetry: true,
});

@@ -38,2 +37,3 @@ const trendingSearch = await client.trendingSearch();

- timeout (optional): The http timeout, default 30s
- autoRetry (optional): Auto retry if the http response code is 429 - to many request

@@ -40,0 +40,0 @@ ## Supported API method

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc