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.8 to 0.0.9

22

dist/CoinGeckoClient.d.ts
import { PLATFORMS } from './Enum';
import { IndexItem, CoinListResponseItem, CoinMarket, PingResponse, TrendingResponse, SimplePriceResponse, TokenPriceResponse, CoinFullInfo, CoinTickerResponse, CoinHistoryResponse, CoinMarketChartResponse, CoinStatusUpdateResponse, Exchange, NameIdPair, ExchangeId, ExchangeIdTickerResponse, FinanceProduct, FinancePlatform, Derivative, DerivativeExchange, EventResponse, EventCountryResponse, ExchangeRatesResponse, GlobalResponse, GlobalDefiResponse } from './Inteface';
import { IndexItem, CoinListResponseItem, CoinMarket, PingResponse, TrendingResponse, SimplePriceResponse, TokenPriceResponse, CoinFullInfo, CoinTickerResponse, CoinHistoryResponse, CoinMarketChartResponse, CoinStatusUpdateResponse, Exchange, NameIdPair, ExchangeId, ExchangeIdTickerResponse, FinanceProduct, FinancePlatform, Derivative, DerivativeExchange, EventResponse, EventCountryResponse, ExchangeRatesResponse, GlobalResponse, GlobalDefiResponse, Options } from './Inteface';
/**
* The wrap client to access all api on coin gecko
*/
export declare class CoinGeckoClient {
apiV3Url: string;
options: Options;
/**
* Constructor
* @param options the options passed for client library, at the moment only timeout are support
*/
constructor(options?: Options);
private withPathParams;
/**
* Make HTTP request to the given endpoint
* @param url the full https URL
* @returns json content
*/
private httpGet;
/**
* Generic function to make request use in internal function
* @param action
* @param params
* @returns
*/
private makeRequest;

@@ -8,0 +28,0 @@ /**

@@ -18,5 +18,16 @@ "use strict";

const Enum_1 = require("./Enum");
/**
* The wrap client to access all api on coin gecko
*/
class CoinGeckoClient {
constructor() {
/**
* Constructor
* @param options the options passed for client library, at the moment only timeout are support
*/
constructor(options) {
this.apiV3Url = 'https://api.coingecko.com/api/v3';
this.options = {
timeout: 30000,
};
this.options = Object.assign(Object.assign({}, this.options), options);
}

@@ -30,2 +41,7 @@ withPathParams(path, replacements = {}) {

}
/**
* Make HTTP request to the given endpoint
* @param url the full https URL
* @returns json content
*/
httpGet(url) {

@@ -38,7 +54,7 @@ return __awaiter(this, void 0, void 0, function* () {

},
timeout: 60000, // in ms
timeout: this.options.timeout, // in ms
};
return new Promise((resolve, reject) => {
const req = https_1.default.request(url, options, (res) => {
if (res.statusCode < 200 || res.statusCode > 299) {
if (res.statusCode && (res.statusCode < 200 || res.statusCode > 299)) {
// reject(new Error(`HTTP status code ${res.statusCode}`));

@@ -58,3 +74,3 @@ }

req.destroy();
reject(new Error('Request time out'));
reject(new Error(`HTTP Request timeout after ${this.options.timeout}`));
});

@@ -65,2 +81,8 @@ req.end();

}
/**
* Generic function to make request use in internal function
* @param action
* @param params
* @returns
*/
makeRequest(action, params = {}) {

@@ -67,0 +89,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -532,1 +532,4 @@ import { PLATFORMS } from './Enum';

export declare type GlobalDefiResponse = ResponseWithData<GlobalDefiData>;
export interface Options {
timeout?: number;
}

2

package.json
{
"name": "coingecko-api-v3",
"version": "0.0.8",
"version": "0.0.9",
"description": "The nodejs api library for accessing coingecko api v3 , develop with typescript",

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

@@ -5,7 +5,11 @@ # coingecko-api-v3

[![codecov](https://codecov.io/gh/samuraitruong/coingecko-api-v3/branch/main/graph/badge.svg?token=A7P9GCFGN2)](https://codecov.io/gh/samuraitruong/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

@@ -20,6 +24,13 @@ ## Get started

```js
const client = new CoinGeckoClient();
import { CoinGeckoClient } from 'coingecko-api-v3';
const client = new CoinGeckoClient({
timeout: 10000,
});
const trendingSearch = await client.trendingSearch();
```
## Options
- timeout (optional): The http timeout, default 30s
## Supported API method

@@ -26,0 +37,0 @@

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