@avalabs/core-coingecko-sdk 3.1.0-canary.f2a8d63.0 → 3.1.0-canary.f49cb8a.0
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/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -5
- package/esm/http.d.ts +5 -5
- package/esm/http.js +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1 +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`]}}))})),_};
|
|
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={},o){return new e.HttpClient(t,r,o)}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={},t){return p(n,e,t)},exports.getCoinGeckoHttp=p,exports.getDevProxiedCoingeckoHttp=function(e={},t){return p(i,{...e,method:"POST"},t)},exports.getProCoingeckoHttp=function(e={},t){return p(o,e,t)},exports.getProxiedCoingeckoHttp=function(e={},t){return p(s,{...e,method:"POST"},t)},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`]}}))})),_};
|
package/dist/index.d.ts
CHANGED
|
@@ -406,11 +406,11 @@ declare const DEV_COINGECKO_PROXY_URL: "https://proxy-api-dev.avax.network/proxy
|
|
|
406
406
|
* otherwise requests will not work because the proxy worker only accepts `POST` requests.
|
|
407
407
|
* @returns
|
|
408
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;
|
|
409
|
+
declare function getCoinGeckoHttp(url?: typeof COINGECKO_URL | typeof COINGECKO_PRO_URL | typeof COINGECKO_PROXY_URL | typeof DEV_COINGECKO_PROXY_URL, options?: HttpOptions, fetchFn?: typeof fetch): HttpClient;
|
|
410
|
+
declare function getProxiedCoingeckoHttp(options?: HttpOptions, fetchFn?: typeof fetch): HttpClient;
|
|
411
|
+
declare function getDevProxiedCoingeckoHttp(options?: HttpOptions, fetchFn?: typeof fetch): HttpClient;
|
|
412
|
+
declare function getBasicCoingeckoHttp(options?: HttpOptions, fetchFn?: typeof fetch): HttpClient;
|
|
413
|
+
declare function getProCoingeckoHttp(options?: HttpOptions, fetchFn?: typeof fetch): HttpClient;
|
|
414
414
|
|
|
415
415
|
/**
|
|
416
416
|
* Get the current price of any cryptocurrencies in any other supported currencies that you need.
|
package/esm/http.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ import { COINGECKO_URL, COINGECKO_PRO_URL, COINGECKO_PROXY_URL, DEV_COINGECKO_PR
|
|
|
9
9
|
* otherwise requests will not work because the proxy worker only accepts `POST` requests.
|
|
10
10
|
* @returns
|
|
11
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;
|
|
12
|
+
declare function getCoinGeckoHttp(url?: typeof COINGECKO_URL | typeof COINGECKO_PRO_URL | typeof COINGECKO_PROXY_URL | typeof DEV_COINGECKO_PROXY_URL, options?: HttpOptions, fetchFn?: typeof fetch): HttpClient;
|
|
13
|
+
declare function getProxiedCoingeckoHttp(options?: HttpOptions, fetchFn?: typeof fetch): HttpClient;
|
|
14
|
+
declare function getDevProxiedCoingeckoHttp(options?: HttpOptions, fetchFn?: typeof fetch): HttpClient;
|
|
15
|
+
declare function getBasicCoingeckoHttp(options?: HttpOptions, fetchFn?: typeof fetch): HttpClient;
|
|
16
|
+
declare function getProCoingeckoHttp(options?: HttpOptions, fetchFn?: typeof fetch): HttpClient;
|
|
17
17
|
|
|
18
18
|
export { getBasicCoingeckoHttp, getCoinGeckoHttp, getDevProxiedCoingeckoHttp, getProCoingeckoHttp, getProxiedCoingeckoHttp };
|
package/esm/http.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HttpClient as n}from"@avalabs/core-utils-sdk";import{COINGECKO_URL as t,DEV_COINGECKO_PROXY_URL as r,COINGECKO_PRO_URL as o,COINGECKO_PROXY_URL as u}from"./constants.js";function e(r=t,o={}){return new n(r,o)}function i(n={}){return e(u,{...n,method:"POST"})}function c(n={}){return e(r,{...n,method:"POST"})}function f(n={}){return e(t,n)}function m(n={}){return e(o,n)}export{f as getBasicCoingeckoHttp,e as getCoinGeckoHttp,c as getDevProxiedCoingeckoHttp,m as getProCoingeckoHttp,i as getProxiedCoingeckoHttp};
|
|
1
|
+
import{HttpClient as n}from"@avalabs/core-utils-sdk";import{COINGECKO_URL as t,DEV_COINGECKO_PROXY_URL as r,COINGECKO_PRO_URL as o,COINGECKO_PROXY_URL as u}from"./constants.js";function e(r=t,o={},u){return new n(r,o,u)}function i(n={},t){return e(u,{...n,method:"POST"},t)}function c(n={},t){return e(r,{...n,method:"POST"},t)}function f(n={},r){return e(t,n,r)}function m(n={},t){return e(o,n,t)}export{f as getBasicCoingeckoHttp,e as getCoinGeckoHttp,c as getDevProxiedCoingeckoHttp,m as getProCoingeckoHttp,i as getProxiedCoingeckoHttp};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avalabs/core-coingecko-sdk",
|
|
3
|
-
"version": "3.1.0-canary.
|
|
3
|
+
"version": "3.1.0-canary.f49cb8a.0+f49cb8a",
|
|
4
4
|
"license": "Limited Ecosystem License",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"lint": "eslint --fix -c ./.eslintrc.cjs \"src/**/*.ts*\""
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@avalabs/core-utils-sdk": "3.1.0-canary.
|
|
29
|
+
"@avalabs/core-utils-sdk": "3.1.0-canary.f49cb8a.0+f49cb8a"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "f49cb8aad4f8ae1da1c44b8e337319eec8c8839f"
|
|
32
32
|
}
|