@avalabs/core-coingecko-sdk 2.8.0-alpha.197
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +38 -0
- package/dist/index.d.ts +445 -0
- package/dist/index.js +1 -0
- package/esm/coinsContractInfo.d.ts +15 -0
- package/esm/coinsContractInfo.js +1 -0
- package/esm/coinsContractMarketChart.d.ts +17 -0
- package/esm/coinsContractMarketChart.js +1 -0
- package/esm/coinsContractMarketChartRange.d.ts +18 -0
- package/esm/coinsContractMarketChartRange.js +1 -0
- package/esm/coinsInfo.d.ts +13 -0
- package/esm/coinsInfo.js +1 -0
- package/esm/coinsMarket.d.ts +18 -0
- package/esm/coinsMarket.js +1 -0
- package/esm/coinsMarketChart.d.ts +16 -0
- package/esm/coinsMarketChart.js +1 -0
- package/esm/coinsMarketChartRange.d.ts +17 -0
- package/esm/coinsMarketChartRange.js +1 -0
- package/esm/coinsSearch.d.ts +13 -0
- package/esm/coinsSearch.js +1 -0
- package/esm/constants.d.ts +8 -0
- package/esm/constants.js +1 -0
- package/esm/helpers.js +1 -0
- package/esm/http.d.ts +18 -0
- package/esm/http.js +1 -0
- package/esm/index.d.ts +13 -0
- package/esm/index.js +1 -0
- package/esm/models.d.ts +297 -0
- package/esm/models.js +1 -0
- package/esm/simplePrice.d.ts +19 -0
- package/esm/simplePrice.js +1 -0
- package/esm/simpleTokenPrice.d.ts +19 -0
- package/esm/simpleTokenPrice.js +1 -0
- package/package.json +25 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Copyright (C) 2021, Ava Labs, Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Subject to the limited license below (**”License””), you may not, and you may not permit anyone else to, copy, reproduce, aggregate, republish, download, post, distribute, license, sublicense, reverse engineer, modify, or create derivative works based on this software (collectively, **“Software”**).
|
|
4
|
+
|
|
5
|
+
You are hereby granted a limited, non-exclusive, non-sublicensable and non-transferable license to download and use the Software as-is solely (i) for use in connection with the Avalanche Public Blockchain platform, having a NetworkID of 1 (Mainnet) or 5 (Fuji), and associated blockchains, comprised exclusively of the Avalanche X-Chain, C-Chain, P-Chain and any subnets linked to the P-Chain (**“Avalanche Authorized Platform”**) or (ii) for non-production, testing or research purposes without any commercial application within the Avalanche ecosystem (**“Non-Commercial Use”**); provided that, in each case, you may not use or allow use of the Software (a) in connection with any forks of the Avalanche Authorized Platform, (b) in any manner not operationally connected to the Avalanche Authorized Platform other than for Non-Commercial Use, or (c) to the extent the number of monthly active users or the number of total installs of any software that uses the Software across all versions thereof exceeds 10,000 at any time. You may not modify or alter the Software in any way.
|
|
6
|
+
|
|
7
|
+
You hereby acknowledge and agree to the terms set forth at www.avalabs.org/important-notice.
|
|
8
|
+
|
|
9
|
+
**TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED ON AN “AS IS” BASIS, AND AVA LABS EXPRESSLY DISCLAIMS AND EXCLUDES ALL REPRESENTATIONS, WARRANTIES AND OTHER TERMS AND CONDITIONS, WHETHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION BY OPERATION OF LAW OR BY CUSTOM, STATUTE OR OTHERWISE, AND INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTY, TERM, OR CONDITION OF NON-INFRINGEMENT, MERCHANTABILITY, TITLE, OR FITNESS FOR PARTICULAR PURPOSE. YOU USE THE SOFTWARE AT YOUR OWN RISK. AVA LABS EXPRESSLY DISCLAIMS ALL LIABILITY (INCLUDING FOR ALL DIRECT, CONSEQUENTIAL OR OTHER DAMAGES OR LOSSES) RELATED TO ANY USE OF THE SOFTWARE.**
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# `coingecko-sdk`
|
|
2
|
+
|
|
3
|
+
> TODO: description
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
const {
|
|
9
|
+
getBasicCoingeckoHttp,
|
|
10
|
+
simpleTokenPrice,
|
|
11
|
+
} = require('@avalabs/coingecko-sdk');
|
|
12
|
+
|
|
13
|
+
const http = getBasicCoingeckoHttp();
|
|
14
|
+
simpleTokenPrice(http, {
|
|
15
|
+
assetPlatformId: 'avalanche',
|
|
16
|
+
tokenAddresses: [TOKEN_ADDRESS1, TOKEN_ADDRESS2],
|
|
17
|
+
marketCap: true,
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## CoinGecko Pro
|
|
22
|
+
|
|
23
|
+
Just pass in the API key and pro HTTP client in order to access the pro api.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
const {
|
|
27
|
+
getProCoingeckoHttp,
|
|
28
|
+
simpleTokenPrice,
|
|
29
|
+
} = require('@avalabs/coingecko-sdk');
|
|
30
|
+
|
|
31
|
+
const http = getProCoingeckoHttp();
|
|
32
|
+
simpleTokenPrice(http, {
|
|
33
|
+
assetPlatformId: 'avalanche',
|
|
34
|
+
tokenAddresses: [TOKEN_ADDRESS1, TOKEN_ADDRESS2],
|
|
35
|
+
marketCap: true,
|
|
36
|
+
coingeckoProApiKey: COINGECKO_PRO_API_KEY,
|
|
37
|
+
});
|
|
38
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { HttpClient, HttpOptions } from '@avalabs/core-utils-sdk';
|
|
2
|
+
|
|
3
|
+
type DaysValueType = number | 'max';
|
|
4
|
+
declare enum VsCurrencyType {
|
|
5
|
+
AED = "aed",
|
|
6
|
+
ARS = "ars",
|
|
7
|
+
AUD = "aud",
|
|
8
|
+
BCH = "bch",
|
|
9
|
+
BDT = "bdt",
|
|
10
|
+
BHD = "bhd",
|
|
11
|
+
BMD = "bmd",
|
|
12
|
+
BNB = "bnb",
|
|
13
|
+
BRL = "brl",
|
|
14
|
+
BTC = "btc",
|
|
15
|
+
CAD = "cad",
|
|
16
|
+
CHF = "chf",
|
|
17
|
+
CLP = "clp",
|
|
18
|
+
CNY = "cny",
|
|
19
|
+
CZK = "czk",
|
|
20
|
+
DKK = "dkk",
|
|
21
|
+
DOT = "dot",
|
|
22
|
+
EOS = "eos",
|
|
23
|
+
ETH = "eth",
|
|
24
|
+
EUR = "eur",
|
|
25
|
+
GBP = "gbp",
|
|
26
|
+
HKD = "hkd",
|
|
27
|
+
HUF = "huf",
|
|
28
|
+
IDR = "idr",
|
|
29
|
+
ILS = "ils",
|
|
30
|
+
INR = "inr",
|
|
31
|
+
JPY = "jpy",
|
|
32
|
+
KRW = "krw",
|
|
33
|
+
KWD = "kwd",
|
|
34
|
+
LKR = "lkr",
|
|
35
|
+
LTC = "ltc",
|
|
36
|
+
MMK = "mmk",
|
|
37
|
+
MXN = "mxn",
|
|
38
|
+
MYR = "myr",
|
|
39
|
+
NGN = "ngn",
|
|
40
|
+
NOK = "nok",
|
|
41
|
+
NZD = "nzd",
|
|
42
|
+
PHP = "php",
|
|
43
|
+
PKR = "pkr",
|
|
44
|
+
PLN = "pln",
|
|
45
|
+
RUB = "rub",
|
|
46
|
+
SAR = "sar",
|
|
47
|
+
SEK = "sek",
|
|
48
|
+
SGD = "sgd",
|
|
49
|
+
THB = "thb",
|
|
50
|
+
TRY = "try",
|
|
51
|
+
TWD = "twd",
|
|
52
|
+
UAH = "uah",
|
|
53
|
+
USD = "usd",
|
|
54
|
+
VEF = "vef",
|
|
55
|
+
VND = "vnd",
|
|
56
|
+
XAG = "xag",
|
|
57
|
+
XAU = "xau",
|
|
58
|
+
XDR = "xdr",
|
|
59
|
+
XLM = "xlm",
|
|
60
|
+
XRP = "xrp",
|
|
61
|
+
YFI = "yfi",
|
|
62
|
+
ZAR = "zar",
|
|
63
|
+
BITS = "bits",
|
|
64
|
+
LINK = "link",
|
|
65
|
+
SATS = "sats"
|
|
66
|
+
}
|
|
67
|
+
type SimplePriceInCurrency = {
|
|
68
|
+
price: number;
|
|
69
|
+
marketCap?: number;
|
|
70
|
+
vol24?: number;
|
|
71
|
+
change24?: number;
|
|
72
|
+
};
|
|
73
|
+
type SimpleTokenPriceParams = {
|
|
74
|
+
assetPlatformId: string;
|
|
75
|
+
tokenAddresses: string[];
|
|
76
|
+
currencies?: VsCurrencyType[];
|
|
77
|
+
marketCap?: boolean;
|
|
78
|
+
vol24?: boolean;
|
|
79
|
+
change24?: boolean;
|
|
80
|
+
lastUpdated?: boolean;
|
|
81
|
+
coinGeckoProApiKey?: string;
|
|
82
|
+
};
|
|
83
|
+
interface SimpleTokenPriceResponse {
|
|
84
|
+
[tokenAddress: string]: {
|
|
85
|
+
[currency in VsCurrencyType]?: SimplePriceInCurrency;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
type SimplePriceParams = {
|
|
89
|
+
coinIds: string[];
|
|
90
|
+
currencies?: VsCurrencyType[];
|
|
91
|
+
marketCap?: boolean;
|
|
92
|
+
vol24?: boolean;
|
|
93
|
+
change24?: boolean;
|
|
94
|
+
lastUpdated?: boolean;
|
|
95
|
+
coinGeckoProApiKey?: string;
|
|
96
|
+
shouldThrow?: boolean;
|
|
97
|
+
};
|
|
98
|
+
interface SimplePriceResponse {
|
|
99
|
+
[tokenId: string]: {
|
|
100
|
+
[currency in VsCurrencyType]?: SimplePriceInCurrency;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
type ContractMarketChartParams = {
|
|
104
|
+
assetPlatformId: string;
|
|
105
|
+
address: string;
|
|
106
|
+
days?: number | 'max';
|
|
107
|
+
currency?: VsCurrencyType;
|
|
108
|
+
coinGeckoProApiKey?: string;
|
|
109
|
+
};
|
|
110
|
+
type ContractMarketChartRangeParams = {
|
|
111
|
+
assetPlatformId: string;
|
|
112
|
+
address: string;
|
|
113
|
+
from: number;
|
|
114
|
+
to: number;
|
|
115
|
+
currency?: VsCurrencyType;
|
|
116
|
+
coinGeckoProApiKey?: string;
|
|
117
|
+
};
|
|
118
|
+
type MarketTuple = [number, number];
|
|
119
|
+
interface ContractMarketChartResponse {
|
|
120
|
+
prices: MarketTuple[];
|
|
121
|
+
marketCaps: MarketTuple[];
|
|
122
|
+
totalVolumes: MarketTuple[];
|
|
123
|
+
}
|
|
124
|
+
type CoinMarketChartParams = {
|
|
125
|
+
coinId: string;
|
|
126
|
+
currency?: VsCurrencyType;
|
|
127
|
+
days?: number | 'max';
|
|
128
|
+
coinGeckoProApiKey?: string;
|
|
129
|
+
};
|
|
130
|
+
type CoinMarketChartResponse = ContractMarketChartResponse;
|
|
131
|
+
type CoinMarketChartRangeParams = {
|
|
132
|
+
coinId: string;
|
|
133
|
+
from: number;
|
|
134
|
+
to: number;
|
|
135
|
+
currency?: VsCurrencyType;
|
|
136
|
+
coinGeckoProApiKey?: string;
|
|
137
|
+
};
|
|
138
|
+
type CoinMarket = {
|
|
139
|
+
id: string;
|
|
140
|
+
symbol: string;
|
|
141
|
+
name: string;
|
|
142
|
+
price: number;
|
|
143
|
+
image: string;
|
|
144
|
+
sparkline_in_7d: {
|
|
145
|
+
price: number[];
|
|
146
|
+
};
|
|
147
|
+
price_change_percentage_24h: number;
|
|
148
|
+
price_change_percentage_1h_in_currency: number;
|
|
149
|
+
price_change_percentage_24h_in_currency: number;
|
|
150
|
+
price_change_percentage_7d_in_currency: number;
|
|
151
|
+
market_cap: number;
|
|
152
|
+
total_volume: number;
|
|
153
|
+
circulating_supply: number;
|
|
154
|
+
current_price: number;
|
|
155
|
+
};
|
|
156
|
+
type CoinMarketChartRangeResponse = ContractMarketChartResponse;
|
|
157
|
+
type CoinsContractInfoParams = {
|
|
158
|
+
assetPlatformId: string;
|
|
159
|
+
address: string;
|
|
160
|
+
coinGeckoProApiKey?: string;
|
|
161
|
+
};
|
|
162
|
+
interface CoinsContractInfoResponse {
|
|
163
|
+
id: string;
|
|
164
|
+
symbol: string;
|
|
165
|
+
name: string;
|
|
166
|
+
asset_platform_id: string;
|
|
167
|
+
platforms: {
|
|
168
|
+
[platformId: string]: string;
|
|
169
|
+
};
|
|
170
|
+
links: {
|
|
171
|
+
homepage: string[];
|
|
172
|
+
blockchain_site: string[];
|
|
173
|
+
official_forum_url: string[];
|
|
174
|
+
chat_url: string[];
|
|
175
|
+
announcement_url: string[];
|
|
176
|
+
twitter_screen_name: string;
|
|
177
|
+
facebook_username: string;
|
|
178
|
+
bitcointalk_thread_identifier: string | null;
|
|
179
|
+
telegram_channel_identifier: string;
|
|
180
|
+
subreddit_url: string | null;
|
|
181
|
+
repos_url: {
|
|
182
|
+
[repo: string]: string[];
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
image: {
|
|
186
|
+
thumb: string;
|
|
187
|
+
small: string;
|
|
188
|
+
large: string;
|
|
189
|
+
};
|
|
190
|
+
market_data: {
|
|
191
|
+
current_price: Record<string, number>;
|
|
192
|
+
circulating_supply: number;
|
|
193
|
+
ath: Record<string, number>;
|
|
194
|
+
ath_change_percentage: Record<string, number>;
|
|
195
|
+
ath_date: Record<string, string>;
|
|
196
|
+
atl: Record<string, number>;
|
|
197
|
+
atl_change_percentage: Record<string, number>;
|
|
198
|
+
atl_date: Record<string, string>;
|
|
199
|
+
market_cap: Record<string, number>;
|
|
200
|
+
market_cap_rank: number;
|
|
201
|
+
fully_diluted_valuation: Record<string, number> | null;
|
|
202
|
+
total_volume: Record<string, number>;
|
|
203
|
+
total_value_locked: Record<string, number>;
|
|
204
|
+
high_24h: Record<string, number>;
|
|
205
|
+
low_24h: Record<string, number>;
|
|
206
|
+
price_change_24h: number;
|
|
207
|
+
price_change_percentage_24h: number;
|
|
208
|
+
price_change_percentage_7d: number;
|
|
209
|
+
price_change_percentage_14d: number;
|
|
210
|
+
price_change_percentage_30d: number;
|
|
211
|
+
price_change_percentage_60d: number;
|
|
212
|
+
price_change_percentage_200d: number;
|
|
213
|
+
price_change_percentage_1y: number;
|
|
214
|
+
};
|
|
215
|
+
tickers: {
|
|
216
|
+
base: string;
|
|
217
|
+
target: string;
|
|
218
|
+
market: {
|
|
219
|
+
name: string;
|
|
220
|
+
identifier: string;
|
|
221
|
+
has_trading_incentive: boolean;
|
|
222
|
+
};
|
|
223
|
+
last: number;
|
|
224
|
+
volume: number;
|
|
225
|
+
converted_last: {
|
|
226
|
+
btc: number;
|
|
227
|
+
eth: number;
|
|
228
|
+
usd: number;
|
|
229
|
+
};
|
|
230
|
+
converted_volume: {
|
|
231
|
+
btc: number;
|
|
232
|
+
eth: number;
|
|
233
|
+
usd: number;
|
|
234
|
+
};
|
|
235
|
+
trust_score: string;
|
|
236
|
+
bid_ask_spread_percentage: number;
|
|
237
|
+
timestamp: string;
|
|
238
|
+
last_traded_at: string;
|
|
239
|
+
last_fetch_at: string;
|
|
240
|
+
is_anomaly: boolean;
|
|
241
|
+
is_stale: boolean;
|
|
242
|
+
trade_url: string | null;
|
|
243
|
+
token_info_url: string | null;
|
|
244
|
+
coin_id: string;
|
|
245
|
+
target_coin_id: string | null;
|
|
246
|
+
}[];
|
|
247
|
+
description: Record<string, string>;
|
|
248
|
+
contract_address: string;
|
|
249
|
+
sentiment_votes_up_percentage: number;
|
|
250
|
+
sentiment_votes_down_percentage: number;
|
|
251
|
+
market_cap_rank: number;
|
|
252
|
+
coingecko_rank: number;
|
|
253
|
+
coingecko_score: number;
|
|
254
|
+
developer_score: number;
|
|
255
|
+
community_score: number;
|
|
256
|
+
liquidity_score: number;
|
|
257
|
+
public_interest_score: number;
|
|
258
|
+
community_data: {
|
|
259
|
+
facebook_likes: null | number;
|
|
260
|
+
twitter_followers: null | number;
|
|
261
|
+
reddit_average_posts_48h: null | number;
|
|
262
|
+
reddit_average_comments_48h: null | number;
|
|
263
|
+
reddit_subscribers: null | number;
|
|
264
|
+
reddit_accounts_active_48h: null | number;
|
|
265
|
+
telegram_channel_user_count: null | number;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
type CoinsInfoParams = {
|
|
269
|
+
coinId: string;
|
|
270
|
+
coinGeckoProApiKey?: string;
|
|
271
|
+
};
|
|
272
|
+
type CoinsSearchParams = {
|
|
273
|
+
query: string;
|
|
274
|
+
coinGeckoProApiKey?: string;
|
|
275
|
+
};
|
|
276
|
+
interface CoinsSearchResponse {
|
|
277
|
+
coins: {
|
|
278
|
+
id: string;
|
|
279
|
+
name: string;
|
|
280
|
+
api_symbol: string;
|
|
281
|
+
symbol: string;
|
|
282
|
+
market_cap_rank: number | null;
|
|
283
|
+
thumb: string;
|
|
284
|
+
larg: string;
|
|
285
|
+
}[];
|
|
286
|
+
}
|
|
287
|
+
type CoinsMarketParams = {
|
|
288
|
+
coinIds?: string[];
|
|
289
|
+
currency?: string;
|
|
290
|
+
sparkline?: boolean;
|
|
291
|
+
priceChangePercentage?: string;
|
|
292
|
+
page?: number;
|
|
293
|
+
perPage?: number;
|
|
294
|
+
order?: string;
|
|
295
|
+
coinGeckoProApiKey?: string;
|
|
296
|
+
};
|
|
297
|
+
type CoinsInfoResponse = Omit<CoinsContractInfoResponse, 'contract_address'>;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Get coin info
|
|
301
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
302
|
+
* @param urlParams URL params for coinsInfo
|
|
303
|
+
* @param urlParams.coinId The coingecko coin id (@see: https://api.coingecko.com/api/v3/coins/list)
|
|
304
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
305
|
+
*/
|
|
306
|
+
declare function coinsInfo(http: HttpClient, { coinId, coinGeckoProApiKey }: CoinsInfoParams): Promise<CoinsInfoResponse>;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Search for coins
|
|
310
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
311
|
+
* @param urlParams URL params for coinsSearch
|
|
312
|
+
* @param urlParams.query The query string
|
|
313
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
314
|
+
*/
|
|
315
|
+
declare function coinsSearch(http: HttpClient, { query, coinGeckoProApiKey }: CoinsSearchParams): Promise<CoinsSearchResponse>;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Get historical market data include sparkline, price, market cap, and 24h volume (granularity auto)
|
|
319
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
320
|
+
* @param urlParams URL params for coinsMarket
|
|
321
|
+
* @param urlParams.coinIds The list of coingecko ids. If undefined, coingecko will return top 100 markets
|
|
322
|
+
* @param urlParams.priceChangePercentage The list of desired price change percentages to show. e.g. '1h, 24h, 7d, 14d, 30d, 200d, 1y'
|
|
323
|
+
* @param urlParams.order Sort fields by result: market_cap_asc, market_cap_desc, volume_asc, volume_desc, id_asc, id_desc
|
|
324
|
+
* @param urlParams.id Coingecko asset_platform (ex: 'avalanche')
|
|
325
|
+
* @param urlParams.currency The target currency of market data (usd, eur, jpy, etc.)
|
|
326
|
+
* @param urlParams.days Data up to number of days ago (eg. 1,14,30,max)
|
|
327
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
328
|
+
*/
|
|
329
|
+
declare function coinsMarket(http: HttpClient, { coinIds, currency, sparkline, page, perPage, order, priceChangePercentage, coinGeckoProApiKey, }: CoinsMarketParams): Promise<CoinMarket[]>;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Get historical market data include price, market cap, and 24h volume (granularity auto)
|
|
333
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
334
|
+
* @param urlParams URL params for coinsContractMarketChart
|
|
335
|
+
* @param urlParams.coinId The coingecko coin id (@see: https://api.coingecko.com/api/v3/coins/list)
|
|
336
|
+
* @param urlParams.id Coingecko asset_platform (ex: 'avalanche')
|
|
337
|
+
* @param urlParams.currency The target currency of market data (usd, eur, jpy, etc.)
|
|
338
|
+
* @param urlParams.days Data up to number of days ago (eg. 1,14,30,max)
|
|
339
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
340
|
+
*/
|
|
341
|
+
declare function coinsMarketChart(http: HttpClient, { coinId, currency, days, coinGeckoProApiKey, }: CoinMarketChartParams): Promise<CoinMarketChartResponse>;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Get historical market data include price, market cap, and 24h volume (granularity auto)
|
|
345
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
346
|
+
* @param urlParams URL params for coinsContractMarketChart
|
|
347
|
+
* @param urlParams.coinId The coingecko coin id (@see: https://api.coingecko.com/api/v3/coins/list)
|
|
348
|
+
* @param urlParams.from from timestamp
|
|
349
|
+
* @param urlParams.to to timestamp
|
|
350
|
+
* @param urlParams.id Coingecko asset_platform (ex: 'avalanche')
|
|
351
|
+
* @param urlParams.currency The target currency of market data (usd, eur, jpy, etc.)
|
|
352
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
353
|
+
*/
|
|
354
|
+
declare function coinsMarketChartRange(http: HttpClient, { coinId, from, to, currency, coinGeckoProApiKey, }: CoinMarketChartRangeParams): Promise<CoinMarketChartRangeResponse>;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Get coin info from contract address
|
|
358
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
359
|
+
* @param urlParams URL params for coinsContractInfo
|
|
360
|
+
* @param urlParams.assetPlatformId The coingecko asset platform (usually the chain, ex: 'avalanche')
|
|
361
|
+
* @param urlParams.address The contract address of the coin.
|
|
362
|
+
* @param urlParams.id Asset platform id
|
|
363
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
364
|
+
*/
|
|
365
|
+
declare function coinsContractInfo(http: HttpClient, { assetPlatformId, address, coinGeckoProApiKey }: CoinsContractInfoParams): Promise<CoinsContractInfoResponse>;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Get historical market data include price, market cap, and 24h volume (granularity auto)
|
|
369
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
370
|
+
* @param urlParams URL params for coinsContractMarketChart
|
|
371
|
+
* @param urlParams.assetPlatformId The coingecko asset platform (usually the chain, ex: 'avalanche')
|
|
372
|
+
* @param urlParams.address Token's contract address
|
|
373
|
+
* @param urlParams.id Coingecko asset_platform (ex: 'avalanche')
|
|
374
|
+
* @param urlParams.currency The target currency of market data (usd, eur, jpy, etc.)
|
|
375
|
+
* @param urlParams.days Data up to number of days ago (eg. 1,14,30,max)
|
|
376
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
377
|
+
*/
|
|
378
|
+
declare function coinsContractMarketChart(http: HttpClient, { assetPlatformId, address, currency, days, coinGeckoProApiKey, }: ContractMarketChartParams): Promise<ContractMarketChartResponse>;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto)
|
|
382
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
383
|
+
* @param urlParams
|
|
384
|
+
* @param urlParams.assetPlatformId The coingecko asset platform (usually the chain, ex: 'avalanche')
|
|
385
|
+
* @param urlParams.address Token's contract address
|
|
386
|
+
* @param urlParams.from From date in UNIX Timestamp (eg. 1392577232)
|
|
387
|
+
* @param urlParams.to To date in UNIX Timestamp (eg. 1422577232)
|
|
388
|
+
* @param urlParams.id The asset platform ID (eg. 'avalanche')
|
|
389
|
+
* @param urlParams.currency The target currency of market data (usd, eur, jpy, etc.)
|
|
390
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
391
|
+
*/
|
|
392
|
+
declare function coinsContractMarketChartRange(http: HttpClient, { assetPlatformId, address, from, to, currency, coinGeckoProApiKey, }: ContractMarketChartRangeParams): Promise<ContractMarketChartResponse>;
|
|
393
|
+
|
|
394
|
+
declare const COINGECKO_URL = "https://api.coingecko.com/api/v3";
|
|
395
|
+
declare const COINGECKO_PRO_URL = "https://pro-api.coingecko.com/api/v3";
|
|
396
|
+
declare const DEV_PROXY_API_WORKER_URL = "https://proxy-api-dev.avax.network";
|
|
397
|
+
declare const PROXY_API_WORKER_URL = "https://proxy-api.avax.network";
|
|
398
|
+
declare const COINGECKO_PROXY_URL: "https://proxy-api.avax.network/proxy/coingecko";
|
|
399
|
+
declare const DEV_COINGECKO_PROXY_URL: "https://proxy-api-dev.avax.network/proxy/coingecko";
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
*
|
|
403
|
+
* @param url
|
|
404
|
+
* @param options - If using the `COINGECKO_PROXY_URL` or `DEV_COINGECKO_PROXY_URL` url,
|
|
405
|
+
* include `{ method: 'POST' }` in the `options`, or use the `getProxiedCoingeckoHttp` or `getDevProxiedCoingeckoHttp` helpers,
|
|
406
|
+
* otherwise requests will not work because the proxy worker only accepts `POST` requests.
|
|
407
|
+
* @returns
|
|
408
|
+
*/
|
|
409
|
+
declare function getCoinGeckoHttp(url?: typeof COINGECKO_URL | typeof COINGECKO_PRO_URL | typeof COINGECKO_PROXY_URL | typeof DEV_COINGECKO_PROXY_URL, options?: HttpOptions): HttpClient;
|
|
410
|
+
declare function getProxiedCoingeckoHttp(options?: HttpOptions): HttpClient;
|
|
411
|
+
declare function getDevProxiedCoingeckoHttp(options?: HttpOptions): HttpClient;
|
|
412
|
+
declare function getBasicCoingeckoHttp(options?: HttpOptions): HttpClient;
|
|
413
|
+
declare function getProCoingeckoHttp(options?: HttpOptions): HttpClient;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Get the current price of any cryptocurrencies in any other supported currencies that you need.
|
|
417
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
418
|
+
* @param urlParams URL params for simpleTokenPrice
|
|
419
|
+
* @param urlParams.assetPlatformId The coingecko asset platform (usually the chain, ex: 'avalanche')
|
|
420
|
+
* @param urlParams.tokenAddresses Array of contract addresses to check for
|
|
421
|
+
* @param urlParams.currencies An array of currencies to check against
|
|
422
|
+
* @param urlParams.marketCap Include market cap
|
|
423
|
+
* @param urlParams.vol24 Include 24 hour volume
|
|
424
|
+
* @param urlParams.change24 Include 24 hour change
|
|
425
|
+
* @param urlParams.lastUpdated Include last updated timestamp
|
|
426
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
427
|
+
*/
|
|
428
|
+
declare function simpleTokenPrice(http: HttpClient, { assetPlatformId, tokenAddresses, currencies, marketCap, vol24, change24, lastUpdated, coinGeckoProApiKey, }: SimpleTokenPriceParams): Promise<SimpleTokenPriceResponse>;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Get the current price of any cryptocurrencies in any other supported currencies that you need.
|
|
432
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
433
|
+
* @param urlParams URL params for simplePrice
|
|
434
|
+
* @param urlParams.ids - id of coins
|
|
435
|
+
* @param urlParams.currency vs currency
|
|
436
|
+
* @param urlParams.marketCap true/false to include market_cap
|
|
437
|
+
* @param urlParams.vol24 true/false to include 24hr_vol,
|
|
438
|
+
* @param urlParams.change24 true/false to include 24h_change
|
|
439
|
+
* @param urlParams.lastUpdated true/false to include last updated at of price
|
|
440
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
441
|
+
* @param urlParams.shouldThrow true/false to throw if request failed with 429
|
|
442
|
+
*/
|
|
443
|
+
declare function simplePrice(http: HttpClient, { coinIds, currencies, marketCap, vol24, change24, lastUpdated, coinGeckoProApiKey, shouldThrow, }: SimplePriceParams): Promise<SimplePriceResponse>;
|
|
444
|
+
|
|
445
|
+
export { COINGECKO_PROXY_URL, COINGECKO_PRO_URL, COINGECKO_URL, CoinMarket, CoinMarketChartParams, CoinMarketChartRangeParams, CoinMarketChartRangeResponse, CoinMarketChartResponse, CoinsContractInfoParams, CoinsContractInfoResponse, CoinsInfoParams, CoinsInfoResponse, CoinsMarketParams, CoinsSearchParams, CoinsSearchResponse, ContractMarketChartParams, ContractMarketChartRangeParams, ContractMarketChartResponse, DEV_COINGECKO_PROXY_URL, DEV_PROXY_API_WORKER_URL, DaysValueType, MarketTuple, PROXY_API_WORKER_URL, SimplePriceInCurrency, SimplePriceParams, SimplePriceResponse, SimpleTokenPriceParams, SimpleTokenPriceResponse, VsCurrencyType, coinsContractInfo, coinsContractMarketChart, coinsContractMarketChartRange, coinsInfo, coinsMarket, coinsMarketChart, coinsMarketChartRange, coinsSearch, getBasicCoingeckoHttp, getCoinGeckoHttp, getDevProxiedCoingeckoHttp, getProCoingeckoHttp, getProxiedCoingeckoHttp, simplePrice, simpleTokenPrice };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("@avalabs/core-utils-sdk");function t(e){return e?{x_cg_pro_api_key:e}:{}}var r=(e=>(e.AED="aed",e.ARS="ars",e.AUD="aud",e.BCH="bch",e.BDT="bdt",e.BHD="bhd",e.BMD="bmd",e.BNB="bnb",e.BRL="brl",e.BTC="btc",e.CAD="cad",e.CHF="chf",e.CLP="clp",e.CNY="cny",e.CZK="czk",e.DKK="dkk",e.DOT="dot",e.EOS="eos",e.ETH="eth",e.EUR="eur",e.GBP="gbp",e.HKD="hkd",e.HUF="huf",e.IDR="idr",e.ILS="ils",e.INR="inr",e.JPY="jpy",e.KRW="krw",e.KWD="kwd",e.LKR="lkr",e.LTC="ltc",e.MMK="mmk",e.MXN="mxn",e.MYR="myr",e.NGN="ngn",e.NOK="nok",e.NZD="nzd",e.PHP="php",e.PKR="pkr",e.PLN="pln",e.RUB="rub",e.SAR="sar",e.SEK="sek",e.SGD="sgd",e.THB="thb",e.TRY="try",e.TWD="twd",e.UAH="uah",e.USD="usd",e.VEF="vef",e.VND="vnd",e.XAG="xag",e.XAU="xau",e.XDR="xdr",e.XLM="xlm",e.XRP="xrp",e.YFI="yfi",e.ZAR="zar",e.BITS="bits",e.LINK="link",e.SATS="sats",e))(r||{});const n="https://api.coingecko.com/api/v3",o="https://pro-api.coingecko.com/api/v3",a="https://proxy-api-dev.avax.network",c="https://proxy-api.avax.network",s=`${c}/proxy/coingecko`,i=`${a}/proxy/coingecko`;function p(t=n,r={}){return new e.HttpClient(t,r)}exports.COINGECKO_PROXY_URL=s,exports.COINGECKO_PRO_URL=o,exports.COINGECKO_URL=n,exports.DEV_COINGECKO_PROXY_URL=i,exports.DEV_PROXY_API_WORKER_URL=a,exports.PROXY_API_WORKER_URL=c,exports.VsCurrencyType=r,exports.coinsContractInfo=async function(e,{assetPlatformId:r,address:n,coinGeckoProApiKey:o}){const a=new URLSearchParams({...t(o)});return await e.get(`/coins/${r}/contract/${n}?${a.toString()}`)},exports.coinsContractMarketChart=async function(e,{assetPlatformId:n,address:o,currency:a=r.USD,days:c=7,coinGeckoProApiKey:s}){const i=new URLSearchParams({vs_currency:a,days:c.toString(),...t(s)}),p=await e.get(`/coins/${n}/contract/${o}/market_chart/?${i.toString()}`);return{prices:p.prices,marketCaps:p.market_caps,totalVolumes:p.total_volumes}},exports.coinsContractMarketChartRange=async function(e,{assetPlatformId:n,address:o,from:a,to:c,currency:s=r.USD,coinGeckoProApiKey:i}){const p=new URLSearchParams({vs_currency:s,from:a.toString(),to:c.toString(),...t(i)}),u=await e.get(`/coins/${n}/contract/${o}/market_chart/range?${p.toString()}`);return{prices:u.prices,marketCaps:u.market_caps,totalVolumes:u.total_volumes}},exports.coinsInfo=async function(e,{coinId:r,coinGeckoProApiKey:n}){const o=new URLSearchParams({...t(n)});return await e.get(`/coins/${r}?${o.toString()}`)},exports.coinsMarket=async function(e,{coinIds:n,currency:o=r.USD,sparkline:a=!1,page:c,perPage:s,order:i,priceChangePercentage:p,coinGeckoProApiKey:u}){const d=new URLSearchParams({vs_currency:o,...t(u)});return n&&d.append("ids",n.join(",")),i&&d.append("order",i),p&&d.append("price_change_percentage",p),a&&d.append("sparkline","true"),s&&d.append("per_page",s.toString()),c&&d.append("page",c.toString()),await e.get(`/coins/markets?${d.toString()}`)},exports.coinsMarketChart=async function(e,{coinId:n,currency:o=r.USD,days:a=7,coinGeckoProApiKey:c}){const s=new URLSearchParams({vs_currency:o,days:a.toString(),...t(c)}),i=await e.get(`/coins/${n}/market_chart/?${s.toString()}`);return{prices:i.prices,marketCaps:i.market_caps,totalVolumes:i.total_volumes}},exports.coinsMarketChartRange=async function(e,{coinId:n,from:o,to:a,currency:c=r.USD,coinGeckoProApiKey:s}){const i=new URLSearchParams({vs_currency:c,from:`${o}`,to:`${a}`,...t(s)}),p=await e.get(`/coins/${n}/market_chart/range?${i.toString()}`);return{prices:p.prices,marketCaps:p.market_caps,totalVolumes:p.total_volumes}},exports.coinsSearch=async function(e,{query:r,coinGeckoProApiKey:n}){const o=new URLSearchParams({query:r,...t(n)});return await e.get(`/search?${o.toString()}`)},exports.getBasicCoingeckoHttp=function(e={}){return p(n,e)},exports.getCoinGeckoHttp=p,exports.getDevProxiedCoingeckoHttp=function(e={}){return p(i,{...e,method:"POST"})},exports.getProCoingeckoHttp=function(e={}){return p(o,e)},exports.getProxiedCoingeckoHttp=function(e={}){return p(s,{...e,method:"POST"})},exports.simplePrice=async function(e,{coinIds:n=[],currencies:o=[r.USD],marketCap:a=!1,vol24:c=!1,change24:s=!1,lastUpdated:i=!1,coinGeckoProApiKey:p,shouldThrow:u=!1}){const d=Array.from({length:Math.ceil(n.length/40)},((e,t)=>n.slice(40*t,40*t+40))).map((e=>{const r=new URLSearchParams({ids:e.join(","),vs_currencies:o.join(","),...t(p)});return a&&r.append("include_market_cap",a.toString()),c&&r.append("include_24hr_vol",c.toString()),s&&r.append("include_24hr_change",s.toString()),i&&r.append("include_last_updated_at",i.toString()),`/simple/price?${r.toString()}`})),g=await Promise.allSettled(d.map((t=>e.get(t))));u&&g.forEach((e=>{if("rejected"===e.status&&e.reason?.toString().includes("429"))throw e.reason}));const _=g.reduce(((e,t)=>({...e,..."fulfilled"===t.status?t.value:{}})),{}),l={};return Object.keys(_).forEach((e=>{const t=_[e];l[e]={},o.forEach((r=>{l[e][r]={price:t[r],change24:t[`${r}_24h_change`],vol24:t[`${r}_24h_vol`],marketCap:t[`${r}_market_cap`]}}))})),l},exports.simpleTokenPrice=async function(e,{assetPlatformId:n,tokenAddresses:o,currencies:a=[r.USD],marketCap:c=!1,vol24:s=!1,change24:i=!1,lastUpdated:p=!1,coinGeckoProApiKey:u}){const d=new URLSearchParams({contract_addresses:o.join(","),vs_currencies:a.join(","),include_market_cap:c.toString(),include_24hr_vol:s.toString(),include_24hr_change:i.toString(),include_last_updated_at:p.toString(),...t(u)}),g=await e.get(`/simple/token_price/${n}?${d.toString()}`),_={};return Object.keys(g).forEach((e=>{const t=g[e];_[e]={},a.forEach((r=>{_[e][r]={price:t[r],change24:t[`${r}_24h_change`],vol24:t[`${r}_24h_vol`],marketCap:t[`${r}_market_cap`]}}))})),_};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HttpClient } from '@avalabs/core-utils-sdk';
|
|
2
|
+
import { CoinsContractInfoParams, CoinsContractInfoResponse } from './models.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get coin info from contract address
|
|
6
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
7
|
+
* @param urlParams URL params for coinsContractInfo
|
|
8
|
+
* @param urlParams.assetPlatformId The coingecko asset platform (usually the chain, ex: 'avalanche')
|
|
9
|
+
* @param urlParams.address The contract address of the coin.
|
|
10
|
+
* @param urlParams.id Asset platform id
|
|
11
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
12
|
+
*/
|
|
13
|
+
declare function coinsContractInfo(http: HttpClient, { assetPlatformId, address, coinGeckoProApiKey }: CoinsContractInfoParams): Promise<CoinsContractInfoResponse>;
|
|
14
|
+
|
|
15
|
+
export { coinsContractInfo };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getApiKeyForSearchParams as r}from"./helpers.js";async function t(t,{assetPlatformId:o,address:e,coinGeckoProApiKey:a}){const n=new URLSearchParams({...r(a)});return await t.get(`/coins/${o}/contract/${e}?${n.toString()}`)}export{t as coinsContractInfo};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HttpClient } from '@avalabs/core-utils-sdk';
|
|
2
|
+
import { ContractMarketChartParams, ContractMarketChartResponse } from './models.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get historical market data include price, market cap, and 24h volume (granularity auto)
|
|
6
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
7
|
+
* @param urlParams URL params for coinsContractMarketChart
|
|
8
|
+
* @param urlParams.assetPlatformId The coingecko asset platform (usually the chain, ex: 'avalanche')
|
|
9
|
+
* @param urlParams.address Token's contract address
|
|
10
|
+
* @param urlParams.id Coingecko asset_platform (ex: 'avalanche')
|
|
11
|
+
* @param urlParams.currency The target currency of market data (usd, eur, jpy, etc.)
|
|
12
|
+
* @param urlParams.days Data up to number of days ago (eg. 1,14,30,max)
|
|
13
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
14
|
+
*/
|
|
15
|
+
declare function coinsContractMarketChart(http: HttpClient, { assetPlatformId, address, currency, days, coinGeckoProApiKey, }: ContractMarketChartParams): Promise<ContractMarketChartResponse>;
|
|
16
|
+
|
|
17
|
+
export { coinsContractMarketChart };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getApiKeyForSearchParams as r}from"./helpers.js";import{VsCurrencyType as t}from"./models.js";async function e(e,{assetPlatformId:s,address:a,currency:o=t.USD,days:c=7,coinGeckoProApiKey:n}){const m=new URLSearchParams({vs_currency:o,days:c.toString(),...r(n)}),i=await e.get(`/coins/${s}/contract/${a}/market_chart/?${m.toString()}`);return{prices:i.prices,marketCaps:i.market_caps,totalVolumes:i.total_volumes}}export{e as coinsContractMarketChart};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HttpClient } from '@avalabs/core-utils-sdk';
|
|
2
|
+
import { ContractMarketChartRangeParams, ContractMarketChartResponse } from './models.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto)
|
|
6
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
7
|
+
* @param urlParams
|
|
8
|
+
* @param urlParams.assetPlatformId The coingecko asset platform (usually the chain, ex: 'avalanche')
|
|
9
|
+
* @param urlParams.address Token's contract address
|
|
10
|
+
* @param urlParams.from From date in UNIX Timestamp (eg. 1392577232)
|
|
11
|
+
* @param urlParams.to To date in UNIX Timestamp (eg. 1422577232)
|
|
12
|
+
* @param urlParams.id The asset platform ID (eg. 'avalanche')
|
|
13
|
+
* @param urlParams.currency The target currency of market data (usd, eur, jpy, etc.)
|
|
14
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
15
|
+
*/
|
|
16
|
+
declare function coinsContractMarketChartRange(http: HttpClient, { assetPlatformId, address, from, to, currency, coinGeckoProApiKey, }: ContractMarketChartRangeParams): Promise<ContractMarketChartResponse>;
|
|
17
|
+
|
|
18
|
+
export { coinsContractMarketChartRange };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getApiKeyForSearchParams as r}from"./helpers.js";import{VsCurrencyType as t}from"./models.js";async function o(o,{assetPlatformId:e,address:a,from:s,to:c,currency:n=t.USD,coinGeckoProApiKey:m}){const i=new URLSearchParams({vs_currency:n,from:s.toString(),to:c.toString(),...r(m)}),p=await o.get(`/coins/${e}/contract/${a}/market_chart/range?${i.toString()}`);return{prices:p.prices,marketCaps:p.market_caps,totalVolumes:p.total_volumes}}export{o as coinsContractMarketChartRange};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpClient } from '@avalabs/core-utils-sdk';
|
|
2
|
+
import { CoinsInfoParams, CoinsInfoResponse } from './models.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get coin info
|
|
6
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
7
|
+
* @param urlParams URL params for coinsInfo
|
|
8
|
+
* @param urlParams.coinId The coingecko coin id (@see: https://api.coingecko.com/api/v3/coins/list)
|
|
9
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
10
|
+
*/
|
|
11
|
+
declare function coinsInfo(http: HttpClient, { coinId, coinGeckoProApiKey }: CoinsInfoParams): Promise<CoinsInfoResponse>;
|
|
12
|
+
|
|
13
|
+
export { coinsInfo };
|
package/esm/coinsInfo.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getApiKeyForSearchParams as o}from"./helpers.js";async function n(n,{coinId:r,coinGeckoProApiKey:e}){const t=new URLSearchParams({...o(e)});return await n.get(`/coins/${r}?${t.toString()}`)}export{n as coinsInfo};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HttpClient } from '@avalabs/core-utils-sdk';
|
|
2
|
+
import { CoinsMarketParams, CoinMarket } from './models.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get historical market data include sparkline, price, market cap, and 24h volume (granularity auto)
|
|
6
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
7
|
+
* @param urlParams URL params for coinsMarket
|
|
8
|
+
* @param urlParams.coinIds The list of coingecko ids. If undefined, coingecko will return top 100 markets
|
|
9
|
+
* @param urlParams.priceChangePercentage The list of desired price change percentages to show. e.g. '1h, 24h, 7d, 14d, 30d, 200d, 1y'
|
|
10
|
+
* @param urlParams.order Sort fields by result: market_cap_asc, market_cap_desc, volume_asc, volume_desc, id_asc, id_desc
|
|
11
|
+
* @param urlParams.id Coingecko asset_platform (ex: 'avalanche')
|
|
12
|
+
* @param urlParams.currency The target currency of market data (usd, eur, jpy, etc.)
|
|
13
|
+
* @param urlParams.days Data up to number of days ago (eg. 1,14,30,max)
|
|
14
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
15
|
+
*/
|
|
16
|
+
declare function coinsMarket(http: HttpClient, { coinIds, currency, sparkline, page, perPage, order, priceChangePercentage, coinGeckoProApiKey, }: CoinsMarketParams): Promise<CoinMarket[]>;
|
|
17
|
+
|
|
18
|
+
export { coinsMarket };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getApiKeyForSearchParams as e}from"./helpers.js";import{VsCurrencyType as r}from"./models.js";async function n(n,{coinIds:p,currency:a=r.USD,sparkline:o=!1,page:t,perPage:c,order:i,priceChangePercentage:s,coinGeckoProApiKey:g}){const d=new URLSearchParams({vs_currency:a,...e(g)});p&&d.append("ids",p.join(",")),i&&d.append("order",i),s&&d.append("price_change_percentage",s),o&&d.append("sparkline","true"),c&&d.append("per_page",c.toString()),t&&d.append("page",t.toString());return await n.get(`/coins/markets?${d.toString()}`)}export{n as coinsMarket};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HttpClient } from '@avalabs/core-utils-sdk';
|
|
2
|
+
import { CoinMarketChartParams, CoinMarketChartResponse } from './models.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get historical market data include price, market cap, and 24h volume (granularity auto)
|
|
6
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
7
|
+
* @param urlParams URL params for coinsContractMarketChart
|
|
8
|
+
* @param urlParams.coinId The coingecko coin id (@see: https://api.coingecko.com/api/v3/coins/list)
|
|
9
|
+
* @param urlParams.id Coingecko asset_platform (ex: 'avalanche')
|
|
10
|
+
* @param urlParams.currency The target currency of market data (usd, eur, jpy, etc.)
|
|
11
|
+
* @param urlParams.days Data up to number of days ago (eg. 1,14,30,max)
|
|
12
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
13
|
+
*/
|
|
14
|
+
declare function coinsMarketChart(http: HttpClient, { coinId, currency, days, coinGeckoProApiKey, }: CoinMarketChartParams): Promise<CoinMarketChartResponse>;
|
|
15
|
+
|
|
16
|
+
export { coinsMarketChart };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getApiKeyForSearchParams as r}from"./helpers.js";import{VsCurrencyType as t}from"./models.js";async function e(e,{coinId:o,currency:s=t.USD,days:a=7,coinGeckoProApiKey:c}){const n=new URLSearchParams({vs_currency:s,days:a.toString(),...r(c)}),i=await e.get(`/coins/${o}/market_chart/?${n.toString()}`);return{prices:i.prices,marketCaps:i.market_caps,totalVolumes:i.total_volumes}}export{e as coinsMarketChart};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HttpClient } from '@avalabs/core-utils-sdk';
|
|
2
|
+
import { CoinMarketChartRangeParams, CoinMarketChartRangeResponse } from './models.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get historical market data include price, market cap, and 24h volume (granularity auto)
|
|
6
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
7
|
+
* @param urlParams URL params for coinsContractMarketChart
|
|
8
|
+
* @param urlParams.coinId The coingecko coin id (@see: https://api.coingecko.com/api/v3/coins/list)
|
|
9
|
+
* @param urlParams.from from timestamp
|
|
10
|
+
* @param urlParams.to to timestamp
|
|
11
|
+
* @param urlParams.id Coingecko asset_platform (ex: 'avalanche')
|
|
12
|
+
* @param urlParams.currency The target currency of market data (usd, eur, jpy, etc.)
|
|
13
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
14
|
+
*/
|
|
15
|
+
declare function coinsMarketChartRange(http: HttpClient, { coinId, from, to, currency, coinGeckoProApiKey, }: CoinMarketChartRangeParams): Promise<CoinMarketChartRangeResponse>;
|
|
16
|
+
|
|
17
|
+
export { coinsMarketChartRange };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getApiKeyForSearchParams as r}from"./helpers.js";import{VsCurrencyType as o}from"./models.js";async function e(e,{coinId:t,from:c,to:a,currency:s=o.USD,coinGeckoProApiKey:m}){const n=new URLSearchParams({vs_currency:s,from:`${c}`,to:`${a}`,...r(m)}),i=await e.get(`/coins/${t}/market_chart/range?${n.toString()}`);return{prices:i.prices,marketCaps:i.market_caps,totalVolumes:i.total_volumes}}export{e as coinsMarketChartRange};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpClient } from '@avalabs/core-utils-sdk';
|
|
2
|
+
import { CoinsSearchParams, CoinsSearchResponse } from './models.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Search for coins
|
|
6
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
7
|
+
* @param urlParams URL params for coinsSearch
|
|
8
|
+
* @param urlParams.query The query string
|
|
9
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
10
|
+
*/
|
|
11
|
+
declare function coinsSearch(http: HttpClient, { query, coinGeckoProApiKey }: CoinsSearchParams): Promise<CoinsSearchResponse>;
|
|
12
|
+
|
|
13
|
+
export { coinsSearch };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getApiKeyForSearchParams as r}from"./helpers.js";async function e(e,{query:o,coinGeckoProApiKey:t}){const n=new URLSearchParams({query:o,...r(t)});return await e.get(`/search?${n.toString()}`)}export{e as coinsSearch};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const COINGECKO_URL = "https://api.coingecko.com/api/v3";
|
|
2
|
+
declare const COINGECKO_PRO_URL = "https://pro-api.coingecko.com/api/v3";
|
|
3
|
+
declare const DEV_PROXY_API_WORKER_URL = "https://proxy-api-dev.avax.network";
|
|
4
|
+
declare const PROXY_API_WORKER_URL = "https://proxy-api.avax.network";
|
|
5
|
+
declare const COINGECKO_PROXY_URL: "https://proxy-api.avax.network/proxy/coingecko";
|
|
6
|
+
declare const DEV_COINGECKO_PROXY_URL: "https://proxy-api-dev.avax.network/proxy/coingecko";
|
|
7
|
+
|
|
8
|
+
export { COINGECKO_PROXY_URL, COINGECKO_PRO_URL, COINGECKO_URL, DEV_COINGECKO_PROXY_URL, DEV_PROXY_API_WORKER_URL, PROXY_API_WORKER_URL };
|
package/esm/constants.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o="https://api.coingecko.com/api/v3",p="https://pro-api.coingecko.com/api/v3",t="https://proxy-api-dev.avax.network",c="https://proxy-api.avax.network",a=`${c}/proxy/coingecko`,i=`${t}/proxy/coingecko`;export{a as COINGECKO_PROXY_URL,p as COINGECKO_PRO_URL,o as COINGECKO_URL,i as DEV_COINGECKO_PROXY_URL,t as DEV_PROXY_API_WORKER_URL,c as PROXY_API_WORKER_URL};
|
package/esm/helpers.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(r){return r?{x_cg_pro_api_key:r}:{}}export{r as getApiKeyForSearchParams};
|
package/esm/http.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HttpOptions, HttpClient } from '@avalabs/core-utils-sdk';
|
|
2
|
+
import { COINGECKO_URL, COINGECKO_PRO_URL, COINGECKO_PROXY_URL, DEV_COINGECKO_PROXY_URL } from './constants.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param url
|
|
7
|
+
* @param options - If using the `COINGECKO_PROXY_URL` or `DEV_COINGECKO_PROXY_URL` url,
|
|
8
|
+
* include `{ method: 'POST' }` in the `options`, or use the `getProxiedCoingeckoHttp` or `getDevProxiedCoingeckoHttp` helpers,
|
|
9
|
+
* otherwise requests will not work because the proxy worker only accepts `POST` requests.
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
declare function getCoinGeckoHttp(url?: typeof COINGECKO_URL | typeof COINGECKO_PRO_URL | typeof COINGECKO_PROXY_URL | typeof DEV_COINGECKO_PROXY_URL, options?: HttpOptions): HttpClient;
|
|
13
|
+
declare function getProxiedCoingeckoHttp(options?: HttpOptions): HttpClient;
|
|
14
|
+
declare function getDevProxiedCoingeckoHttp(options?: HttpOptions): HttpClient;
|
|
15
|
+
declare function getBasicCoingeckoHttp(options?: HttpOptions): HttpClient;
|
|
16
|
+
declare function getProCoingeckoHttp(options?: HttpOptions): HttpClient;
|
|
17
|
+
|
|
18
|
+
export { getBasicCoingeckoHttp, getCoinGeckoHttp, getDevProxiedCoingeckoHttp, getProCoingeckoHttp, getProxiedCoingeckoHttp };
|
package/esm/http.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{HttpClient as n}from"@avalabs/core-utils-sdk";import{COINGECKO_URL as t,COINGECKO_PROXY_URL as r,DEV_COINGECKO_PROXY_URL as o,COINGECKO_PRO_URL as u}from"./constants.js";function e(r=t,o={}){return new n(r,o)}function i(n={}){return e(r,{...n,method:"POST"})}function c(n={}){return e(o,{...n,method:"POST"})}function f(n={}){return e(t,n)}function m(n={}){return e(u,n)}export{f as getBasicCoingeckoHttp,e as getCoinGeckoHttp,c as getDevProxiedCoingeckoHttp,m as getProCoingeckoHttp,i as getProxiedCoingeckoHttp};
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { coinsInfo } from './coinsInfo.js';
|
|
2
|
+
export { coinsSearch } from './coinsSearch.js';
|
|
3
|
+
export { coinsMarket } from './coinsMarket.js';
|
|
4
|
+
export { coinsMarketChart } from './coinsMarketChart.js';
|
|
5
|
+
export { coinsMarketChartRange } from './coinsMarketChartRange.js';
|
|
6
|
+
export { coinsContractInfo } from './coinsContractInfo.js';
|
|
7
|
+
export { coinsContractMarketChart } from './coinsContractMarketChart.js';
|
|
8
|
+
export { coinsContractMarketChartRange } from './coinsContractMarketChartRange.js';
|
|
9
|
+
export { COINGECKO_PROXY_URL, COINGECKO_PRO_URL, COINGECKO_URL, DEV_COINGECKO_PROXY_URL, DEV_PROXY_API_WORKER_URL, PROXY_API_WORKER_URL } from './constants.js';
|
|
10
|
+
export { getBasicCoingeckoHttp, getCoinGeckoHttp, getDevProxiedCoingeckoHttp, getProCoingeckoHttp, getProxiedCoingeckoHttp } from './http.js';
|
|
11
|
+
export { CoinMarket, CoinMarketChartParams, CoinMarketChartRangeParams, CoinMarketChartRangeResponse, CoinMarketChartResponse, CoinsContractInfoParams, CoinsContractInfoResponse, CoinsInfoParams, CoinsInfoResponse, CoinsMarketParams, CoinsSearchParams, CoinsSearchResponse, ContractMarketChartParams, ContractMarketChartRangeParams, ContractMarketChartResponse, DaysValueType, MarketTuple, SimplePriceInCurrency, SimplePriceParams, SimplePriceResponse, SimpleTokenPriceParams, SimpleTokenPriceResponse, VsCurrencyType } from './models.js';
|
|
12
|
+
export { simpleTokenPrice } from './simpleTokenPrice.js';
|
|
13
|
+
export { simplePrice } from './simplePrice.js';
|
package/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{coinsInfo}from"./coinsInfo.js";export{coinsSearch}from"./coinsSearch.js";export{coinsMarket}from"./coinsMarket.js";export{coinsMarketChart}from"./coinsMarketChart.js";export{coinsMarketChartRange}from"./coinsMarketChartRange.js";export{coinsContractInfo}from"./coinsContractInfo.js";export{coinsContractMarketChart}from"./coinsContractMarketChart.js";export{coinsContractMarketChartRange}from"./coinsContractMarketChartRange.js";export{COINGECKO_PROXY_URL,COINGECKO_PRO_URL,COINGECKO_URL,DEV_COINGECKO_PROXY_URL,DEV_PROXY_API_WORKER_URL,PROXY_API_WORKER_URL}from"./constants.js";export{getBasicCoingeckoHttp,getCoinGeckoHttp,getDevProxiedCoingeckoHttp,getProCoingeckoHttp,getProxiedCoingeckoHttp}from"./http.js";export{VsCurrencyType}from"./models.js";export{simpleTokenPrice}from"./simpleTokenPrice.js";export{simplePrice}from"./simplePrice.js";
|
package/esm/models.d.ts
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
type DaysValueType = number | 'max';
|
|
2
|
+
declare enum VsCurrencyType {
|
|
3
|
+
AED = "aed",
|
|
4
|
+
ARS = "ars",
|
|
5
|
+
AUD = "aud",
|
|
6
|
+
BCH = "bch",
|
|
7
|
+
BDT = "bdt",
|
|
8
|
+
BHD = "bhd",
|
|
9
|
+
BMD = "bmd",
|
|
10
|
+
BNB = "bnb",
|
|
11
|
+
BRL = "brl",
|
|
12
|
+
BTC = "btc",
|
|
13
|
+
CAD = "cad",
|
|
14
|
+
CHF = "chf",
|
|
15
|
+
CLP = "clp",
|
|
16
|
+
CNY = "cny",
|
|
17
|
+
CZK = "czk",
|
|
18
|
+
DKK = "dkk",
|
|
19
|
+
DOT = "dot",
|
|
20
|
+
EOS = "eos",
|
|
21
|
+
ETH = "eth",
|
|
22
|
+
EUR = "eur",
|
|
23
|
+
GBP = "gbp",
|
|
24
|
+
HKD = "hkd",
|
|
25
|
+
HUF = "huf",
|
|
26
|
+
IDR = "idr",
|
|
27
|
+
ILS = "ils",
|
|
28
|
+
INR = "inr",
|
|
29
|
+
JPY = "jpy",
|
|
30
|
+
KRW = "krw",
|
|
31
|
+
KWD = "kwd",
|
|
32
|
+
LKR = "lkr",
|
|
33
|
+
LTC = "ltc",
|
|
34
|
+
MMK = "mmk",
|
|
35
|
+
MXN = "mxn",
|
|
36
|
+
MYR = "myr",
|
|
37
|
+
NGN = "ngn",
|
|
38
|
+
NOK = "nok",
|
|
39
|
+
NZD = "nzd",
|
|
40
|
+
PHP = "php",
|
|
41
|
+
PKR = "pkr",
|
|
42
|
+
PLN = "pln",
|
|
43
|
+
RUB = "rub",
|
|
44
|
+
SAR = "sar",
|
|
45
|
+
SEK = "sek",
|
|
46
|
+
SGD = "sgd",
|
|
47
|
+
THB = "thb",
|
|
48
|
+
TRY = "try",
|
|
49
|
+
TWD = "twd",
|
|
50
|
+
UAH = "uah",
|
|
51
|
+
USD = "usd",
|
|
52
|
+
VEF = "vef",
|
|
53
|
+
VND = "vnd",
|
|
54
|
+
XAG = "xag",
|
|
55
|
+
XAU = "xau",
|
|
56
|
+
XDR = "xdr",
|
|
57
|
+
XLM = "xlm",
|
|
58
|
+
XRP = "xrp",
|
|
59
|
+
YFI = "yfi",
|
|
60
|
+
ZAR = "zar",
|
|
61
|
+
BITS = "bits",
|
|
62
|
+
LINK = "link",
|
|
63
|
+
SATS = "sats"
|
|
64
|
+
}
|
|
65
|
+
type SimplePriceInCurrency = {
|
|
66
|
+
price: number;
|
|
67
|
+
marketCap?: number;
|
|
68
|
+
vol24?: number;
|
|
69
|
+
change24?: number;
|
|
70
|
+
};
|
|
71
|
+
type SimpleTokenPriceParams = {
|
|
72
|
+
assetPlatformId: string;
|
|
73
|
+
tokenAddresses: string[];
|
|
74
|
+
currencies?: VsCurrencyType[];
|
|
75
|
+
marketCap?: boolean;
|
|
76
|
+
vol24?: boolean;
|
|
77
|
+
change24?: boolean;
|
|
78
|
+
lastUpdated?: boolean;
|
|
79
|
+
coinGeckoProApiKey?: string;
|
|
80
|
+
};
|
|
81
|
+
interface SimpleTokenPriceResponse {
|
|
82
|
+
[tokenAddress: string]: {
|
|
83
|
+
[currency in VsCurrencyType]?: SimplePriceInCurrency;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
type SimplePriceParams = {
|
|
87
|
+
coinIds: string[];
|
|
88
|
+
currencies?: VsCurrencyType[];
|
|
89
|
+
marketCap?: boolean;
|
|
90
|
+
vol24?: boolean;
|
|
91
|
+
change24?: boolean;
|
|
92
|
+
lastUpdated?: boolean;
|
|
93
|
+
coinGeckoProApiKey?: string;
|
|
94
|
+
shouldThrow?: boolean;
|
|
95
|
+
};
|
|
96
|
+
interface SimplePriceResponse {
|
|
97
|
+
[tokenId: string]: {
|
|
98
|
+
[currency in VsCurrencyType]?: SimplePriceInCurrency;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
type ContractMarketChartParams = {
|
|
102
|
+
assetPlatformId: string;
|
|
103
|
+
address: string;
|
|
104
|
+
days?: number | 'max';
|
|
105
|
+
currency?: VsCurrencyType;
|
|
106
|
+
coinGeckoProApiKey?: string;
|
|
107
|
+
};
|
|
108
|
+
type ContractMarketChartRangeParams = {
|
|
109
|
+
assetPlatformId: string;
|
|
110
|
+
address: string;
|
|
111
|
+
from: number;
|
|
112
|
+
to: number;
|
|
113
|
+
currency?: VsCurrencyType;
|
|
114
|
+
coinGeckoProApiKey?: string;
|
|
115
|
+
};
|
|
116
|
+
type MarketTuple = [number, number];
|
|
117
|
+
interface ContractMarketChartResponse {
|
|
118
|
+
prices: MarketTuple[];
|
|
119
|
+
marketCaps: MarketTuple[];
|
|
120
|
+
totalVolumes: MarketTuple[];
|
|
121
|
+
}
|
|
122
|
+
type CoinMarketChartParams = {
|
|
123
|
+
coinId: string;
|
|
124
|
+
currency?: VsCurrencyType;
|
|
125
|
+
days?: number | 'max';
|
|
126
|
+
coinGeckoProApiKey?: string;
|
|
127
|
+
};
|
|
128
|
+
type CoinMarketChartResponse = ContractMarketChartResponse;
|
|
129
|
+
type CoinMarketChartRangeParams = {
|
|
130
|
+
coinId: string;
|
|
131
|
+
from: number;
|
|
132
|
+
to: number;
|
|
133
|
+
currency?: VsCurrencyType;
|
|
134
|
+
coinGeckoProApiKey?: string;
|
|
135
|
+
};
|
|
136
|
+
type CoinMarket = {
|
|
137
|
+
id: string;
|
|
138
|
+
symbol: string;
|
|
139
|
+
name: string;
|
|
140
|
+
price: number;
|
|
141
|
+
image: string;
|
|
142
|
+
sparkline_in_7d: {
|
|
143
|
+
price: number[];
|
|
144
|
+
};
|
|
145
|
+
price_change_percentage_24h: number;
|
|
146
|
+
price_change_percentage_1h_in_currency: number;
|
|
147
|
+
price_change_percentage_24h_in_currency: number;
|
|
148
|
+
price_change_percentage_7d_in_currency: number;
|
|
149
|
+
market_cap: number;
|
|
150
|
+
total_volume: number;
|
|
151
|
+
circulating_supply: number;
|
|
152
|
+
current_price: number;
|
|
153
|
+
};
|
|
154
|
+
type CoinMarketChartRangeResponse = ContractMarketChartResponse;
|
|
155
|
+
type CoinsContractInfoParams = {
|
|
156
|
+
assetPlatformId: string;
|
|
157
|
+
address: string;
|
|
158
|
+
coinGeckoProApiKey?: string;
|
|
159
|
+
};
|
|
160
|
+
interface CoinsContractInfoResponse {
|
|
161
|
+
id: string;
|
|
162
|
+
symbol: string;
|
|
163
|
+
name: string;
|
|
164
|
+
asset_platform_id: string;
|
|
165
|
+
platforms: {
|
|
166
|
+
[platformId: string]: string;
|
|
167
|
+
};
|
|
168
|
+
links: {
|
|
169
|
+
homepage: string[];
|
|
170
|
+
blockchain_site: string[];
|
|
171
|
+
official_forum_url: string[];
|
|
172
|
+
chat_url: string[];
|
|
173
|
+
announcement_url: string[];
|
|
174
|
+
twitter_screen_name: string;
|
|
175
|
+
facebook_username: string;
|
|
176
|
+
bitcointalk_thread_identifier: string | null;
|
|
177
|
+
telegram_channel_identifier: string;
|
|
178
|
+
subreddit_url: string | null;
|
|
179
|
+
repos_url: {
|
|
180
|
+
[repo: string]: string[];
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
image: {
|
|
184
|
+
thumb: string;
|
|
185
|
+
small: string;
|
|
186
|
+
large: string;
|
|
187
|
+
};
|
|
188
|
+
market_data: {
|
|
189
|
+
current_price: Record<string, number>;
|
|
190
|
+
circulating_supply: number;
|
|
191
|
+
ath: Record<string, number>;
|
|
192
|
+
ath_change_percentage: Record<string, number>;
|
|
193
|
+
ath_date: Record<string, string>;
|
|
194
|
+
atl: Record<string, number>;
|
|
195
|
+
atl_change_percentage: Record<string, number>;
|
|
196
|
+
atl_date: Record<string, string>;
|
|
197
|
+
market_cap: Record<string, number>;
|
|
198
|
+
market_cap_rank: number;
|
|
199
|
+
fully_diluted_valuation: Record<string, number> | null;
|
|
200
|
+
total_volume: Record<string, number>;
|
|
201
|
+
total_value_locked: Record<string, number>;
|
|
202
|
+
high_24h: Record<string, number>;
|
|
203
|
+
low_24h: Record<string, number>;
|
|
204
|
+
price_change_24h: number;
|
|
205
|
+
price_change_percentage_24h: number;
|
|
206
|
+
price_change_percentage_7d: number;
|
|
207
|
+
price_change_percentage_14d: number;
|
|
208
|
+
price_change_percentage_30d: number;
|
|
209
|
+
price_change_percentage_60d: number;
|
|
210
|
+
price_change_percentage_200d: number;
|
|
211
|
+
price_change_percentage_1y: number;
|
|
212
|
+
};
|
|
213
|
+
tickers: {
|
|
214
|
+
base: string;
|
|
215
|
+
target: string;
|
|
216
|
+
market: {
|
|
217
|
+
name: string;
|
|
218
|
+
identifier: string;
|
|
219
|
+
has_trading_incentive: boolean;
|
|
220
|
+
};
|
|
221
|
+
last: number;
|
|
222
|
+
volume: number;
|
|
223
|
+
converted_last: {
|
|
224
|
+
btc: number;
|
|
225
|
+
eth: number;
|
|
226
|
+
usd: number;
|
|
227
|
+
};
|
|
228
|
+
converted_volume: {
|
|
229
|
+
btc: number;
|
|
230
|
+
eth: number;
|
|
231
|
+
usd: number;
|
|
232
|
+
};
|
|
233
|
+
trust_score: string;
|
|
234
|
+
bid_ask_spread_percentage: number;
|
|
235
|
+
timestamp: string;
|
|
236
|
+
last_traded_at: string;
|
|
237
|
+
last_fetch_at: string;
|
|
238
|
+
is_anomaly: boolean;
|
|
239
|
+
is_stale: boolean;
|
|
240
|
+
trade_url: string | null;
|
|
241
|
+
token_info_url: string | null;
|
|
242
|
+
coin_id: string;
|
|
243
|
+
target_coin_id: string | null;
|
|
244
|
+
}[];
|
|
245
|
+
description: Record<string, string>;
|
|
246
|
+
contract_address: string;
|
|
247
|
+
sentiment_votes_up_percentage: number;
|
|
248
|
+
sentiment_votes_down_percentage: number;
|
|
249
|
+
market_cap_rank: number;
|
|
250
|
+
coingecko_rank: number;
|
|
251
|
+
coingecko_score: number;
|
|
252
|
+
developer_score: number;
|
|
253
|
+
community_score: number;
|
|
254
|
+
liquidity_score: number;
|
|
255
|
+
public_interest_score: number;
|
|
256
|
+
community_data: {
|
|
257
|
+
facebook_likes: null | number;
|
|
258
|
+
twitter_followers: null | number;
|
|
259
|
+
reddit_average_posts_48h: null | number;
|
|
260
|
+
reddit_average_comments_48h: null | number;
|
|
261
|
+
reddit_subscribers: null | number;
|
|
262
|
+
reddit_accounts_active_48h: null | number;
|
|
263
|
+
telegram_channel_user_count: null | number;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
type CoinsInfoParams = {
|
|
267
|
+
coinId: string;
|
|
268
|
+
coinGeckoProApiKey?: string;
|
|
269
|
+
};
|
|
270
|
+
type CoinsSearchParams = {
|
|
271
|
+
query: string;
|
|
272
|
+
coinGeckoProApiKey?: string;
|
|
273
|
+
};
|
|
274
|
+
interface CoinsSearchResponse {
|
|
275
|
+
coins: {
|
|
276
|
+
id: string;
|
|
277
|
+
name: string;
|
|
278
|
+
api_symbol: string;
|
|
279
|
+
symbol: string;
|
|
280
|
+
market_cap_rank: number | null;
|
|
281
|
+
thumb: string;
|
|
282
|
+
larg: string;
|
|
283
|
+
}[];
|
|
284
|
+
}
|
|
285
|
+
type CoinsMarketParams = {
|
|
286
|
+
coinIds?: string[];
|
|
287
|
+
currency?: string;
|
|
288
|
+
sparkline?: boolean;
|
|
289
|
+
priceChangePercentage?: string;
|
|
290
|
+
page?: number;
|
|
291
|
+
perPage?: number;
|
|
292
|
+
order?: string;
|
|
293
|
+
coinGeckoProApiKey?: string;
|
|
294
|
+
};
|
|
295
|
+
type CoinsInfoResponse = Omit<CoinsContractInfoResponse, 'contract_address'>;
|
|
296
|
+
|
|
297
|
+
export { CoinMarket, CoinMarketChartParams, CoinMarketChartRangeParams, CoinMarketChartRangeResponse, CoinMarketChartResponse, CoinsContractInfoParams, CoinsContractInfoResponse, CoinsInfoParams, CoinsInfoResponse, CoinsMarketParams, CoinsSearchParams, CoinsSearchResponse, ContractMarketChartParams, ContractMarketChartRangeParams, ContractMarketChartResponse, DaysValueType, MarketTuple, SimplePriceInCurrency, SimplePriceParams, SimplePriceResponse, SimpleTokenPriceParams, SimpleTokenPriceResponse, VsCurrencyType };
|
package/esm/models.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=(d=>(d.AED="aed",d.ARS="ars",d.AUD="aud",d.BCH="bch",d.BDT="bdt",d.BHD="bhd",d.BMD="bmd",d.BNB="bnb",d.BRL="brl",d.BTC="btc",d.CAD="cad",d.CHF="chf",d.CLP="clp",d.CNY="cny",d.CZK="czk",d.DKK="dkk",d.DOT="dot",d.EOS="eos",d.ETH="eth",d.EUR="eur",d.GBP="gbp",d.HKD="hkd",d.HUF="huf",d.IDR="idr",d.ILS="ils",d.INR="inr",d.JPY="jpy",d.KRW="krw",d.KWD="kwd",d.LKR="lkr",d.LTC="ltc",d.MMK="mmk",d.MXN="mxn",d.MYR="myr",d.NGN="ngn",d.NOK="nok",d.NZD="nzd",d.PHP="php",d.PKR="pkr",d.PLN="pln",d.RUB="rub",d.SAR="sar",d.SEK="sek",d.SGD="sgd",d.THB="thb",d.TRY="try",d.TWD="twd",d.UAH="uah",d.USD="usd",d.VEF="vef",d.VND="vnd",d.XAG="xag",d.XAU="xau",d.XDR="xdr",d.XLM="xlm",d.XRP="xrp",d.YFI="yfi",d.ZAR="zar",d.BITS="bits",d.LINK="link",d.SATS="sats",d))(d||{});export{d as VsCurrencyType};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HttpClient } from '@avalabs/core-utils-sdk';
|
|
2
|
+
import { SimplePriceParams, SimplePriceResponse } from './models.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get the current price of any cryptocurrencies in any other supported currencies that you need.
|
|
6
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
7
|
+
* @param urlParams URL params for simplePrice
|
|
8
|
+
* @param urlParams.ids - id of coins
|
|
9
|
+
* @param urlParams.currency vs currency
|
|
10
|
+
* @param urlParams.marketCap true/false to include market_cap
|
|
11
|
+
* @param urlParams.vol24 true/false to include 24hr_vol,
|
|
12
|
+
* @param urlParams.change24 true/false to include 24h_change
|
|
13
|
+
* @param urlParams.lastUpdated true/false to include last updated at of price
|
|
14
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
15
|
+
* @param urlParams.shouldThrow true/false to throw if request failed with 429
|
|
16
|
+
*/
|
|
17
|
+
declare function simplePrice(http: HttpClient, { coinIds, currencies, marketCap, vol24, change24, lastUpdated, coinGeckoProApiKey, shouldThrow, }: SimplePriceParams): Promise<SimplePriceResponse>;
|
|
18
|
+
|
|
19
|
+
export { simplePrice };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getApiKeyForSearchParams as e}from"./helpers.js";import{VsCurrencyType as t}from"./models.js";async function r(r,{coinIds:a=[],currencies:n=[t.USD],marketCap:o=!1,vol24:c=!1,change24:i=!1,lastUpdated:s=!1,coinGeckoProApiKey:l,shouldThrow:p=!1}){const d=Array.from({length:Math.ceil(a.length/40)},((e,t)=>a.slice(40*t,40*t+40))).map((t=>{const r=new URLSearchParams({ids:t.join(","),vs_currencies:n.join(","),...e(l)});return o&&r.append("include_market_cap",o.toString()),c&&r.append("include_24hr_vol",c.toString()),i&&r.append("include_24hr_change",i.toString()),s&&r.append("include_last_updated_at",s.toString()),`/simple/price?${r.toString()}`})),h=await Promise.allSettled(d.map((e=>r.get(e))));p&&h.forEach((e=>{if("rejected"===e.status&&e.reason?.toString().includes("429"))throw e.reason}));const u=h.reduce(((e,t)=>({...e,..."fulfilled"===t.status?t.value:{}})),{}),_={};return Object.keys(u).forEach((e=>{const t=u[e];_[e]={},n.forEach((r=>{_[e][r]={price:t[r],change24:t[`${r}_24h_change`],vol24:t[`${r}_24h_vol`],marketCap:t[`${r}_market_cap`]}}))})),_}export{r as simplePrice};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HttpClient } from '@avalabs/core-utils-sdk';
|
|
2
|
+
import { SimpleTokenPriceParams, SimpleTokenPriceResponse } from './models.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get the current price of any cryptocurrencies in any other supported currencies that you need.
|
|
6
|
+
* @param http HTTP client for basic or pro coingecko API
|
|
7
|
+
* @param urlParams URL params for simpleTokenPrice
|
|
8
|
+
* @param urlParams.assetPlatformId The coingecko asset platform (usually the chain, ex: 'avalanche')
|
|
9
|
+
* @param urlParams.tokenAddresses Array of contract addresses to check for
|
|
10
|
+
* @param urlParams.currencies An array of currencies to check against
|
|
11
|
+
* @param urlParams.marketCap Include market cap
|
|
12
|
+
* @param urlParams.vol24 Include 24 hour volume
|
|
13
|
+
* @param urlParams.change24 Include 24 hour change
|
|
14
|
+
* @param urlParams.lastUpdated Include last updated timestamp
|
|
15
|
+
* @param urlParams.coinGeckoProApiKey API key (x_cg_pro_api_key) for coingecko pro
|
|
16
|
+
*/
|
|
17
|
+
declare function simpleTokenPrice(http: HttpClient, { assetPlatformId, tokenAddresses, currencies, marketCap, vol24, change24, lastUpdated, coinGeckoProApiKey, }: SimpleTokenPriceParams): Promise<SimpleTokenPriceResponse>;
|
|
18
|
+
|
|
19
|
+
export { simpleTokenPrice };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getApiKeyForSearchParams as e}from"./helpers.js";import{VsCurrencyType as t}from"./models.js";async function r(r,{assetPlatformId:a,tokenAddresses:o,currencies:c=[t.USD],marketCap:n=!1,vol24:s=!1,change24:i=!1,lastUpdated:_=!1,coinGeckoProApiKey:d}){const l=new URLSearchParams({contract_addresses:o.join(","),vs_currencies:c.join(","),include_market_cap:n.toString(),include_24hr_vol:s.toString(),include_24hr_change:i.toString(),include_last_updated_at:_.toString(),...e(d)}),p=await r.get(`/simple/token_price/${a}?${l.toString()}`),h={};return Object.keys(p).forEach((e=>{const t=p[e];h[e]={},c.forEach((r=>{h[e][r]={price:t[r],change24:t[`${r}_24h_change`],vol24:t[`${r}_24h_vol`],marketCap:t[`${r}_market_cap`]}}))})),h}export{r as simpleTokenPrice};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@avalabs/core-coingecko-sdk",
|
|
3
|
+
"version": "2.8.0-alpha.197",
|
|
4
|
+
"license": "Limited Ecosystem License",
|
|
5
|
+
"private": false,
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "esm/index.js",
|
|
8
|
+
"typings": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"esm"
|
|
12
|
+
],
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "restricted"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"start": "rollup -c --watch",
|
|
19
|
+
"build": "rollup -c",
|
|
20
|
+
"lint": "eslint --fix -c ./.eslintrc.js \"src/**/*.ts*\""
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@avalabs/core-utils-sdk": "2.8.0-alpha.197"
|
|
24
|
+
}
|
|
25
|
+
}
|