· 4 years ago · Jun 04, 2021, 09:00 PM
1function getCryptoPrice(coin_token) {
2 //var sh1=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
3 //var sh2=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2");
4
5
6
7 //Make sure that you got the API key from Coinmarketcap API dashboard and paste it in sheet_1 on cell B1
8 //var apiKey=sh1.getRange(1, 2).getValue();
9 var apiKey = "APIKEY"
10 //var coin_token = "BNB"
11
12 var url="https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=" + coin_token
13 var requestOptions = {
14 method: 'GET',
15 uri: 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest',
16 qs: {
17 start: 1,
18 limit: 5000,
19 convert: 'USD'
20 },
21 headers: {
22 'X-CMC_PRO_API_KEY': apiKey
23 },
24 json: true,
25 gzip: true
26 };
27
28 var httpRequest= UrlFetchApp.fetch(url, requestOptions);
29 var getContext= httpRequest.getContentText();
30
31 var parseData=JSON.parse(getContext);
32 //sh2.getRange(1, 3).setValue(parseData.data[coin_token].quote.USD.price)
33 return parseData.data[coin_token].quote.USD.price;
34}
35
36function getMarketCap(coin_token) {
37 //Make sure that you got the API key from Coinmarketcap API dashboard and paste it in sheet_1 on cell B1
38 //var apiKey=sh1.getRange(1, 2).getValue();
39 var apiKey = "APIKEY"
40 //var coin_token = "BNB"
41
42 var url="https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=" + coin_token
43 var requestOptions = {
44 method: 'GET',
45 uri: 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest',
46 qs: {
47 start: 1,
48 limit: 5000,
49 convert: 'USD'
50 },
51 headers: {
52 'X-CMC_PRO_API_KEY': apiKey
53 },
54 json: true,
55 gzip: true
56 };
57
58 var httpRequest= UrlFetchApp.fetch(url, requestOptions);
59 var getContext= httpRequest.getContentText();
60
61 var parseData=JSON.parse(getContext);
62 return parseData.data[coin_token].quote.USD.market_cap;
63}
64
65
66function getMarketCap(coin_token) {
67 //Make sure that you got the API key from Coinmarketcap API dashboard and paste it in sheet_1 on cell B1
68 //var apiKey=sh1.getRange(1, 2).getValue();
69 var apiKey = "APIKEY"
70 //var coin_token = "BNB"
71
72 var url="https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=" + coin_token
73 var requestOptions = {
74 method: 'GET',
75 uri: 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest',
76 qs: {
77 start: 1,
78 limit: 5000,
79 convert: 'USD'
80 },
81 headers: {
82 'X-CMC_PRO_API_KEY': apiKey
83 },
84 json: true,
85 gzip: true
86 };
87
88 var httpRequest= UrlFetchApp.fetch(url, requestOptions);
89 var getContext= httpRequest.getContentText();
90
91 var parseData=JSON.parse(getContext);
92 return parseData.data[coin_token].quote.USD.market_cap;
93}
94
95function getCoinLogo(coin_token) {
96 //Make sure that you got the API key from Coinmarketcap API dashboard and paste it in sheet_1 on cell B1
97 //var apiKey=sh1.getRange(1, 2).getValue();
98 var apiKey = "APIKEY"
99 //var coin_token = "ETH"
100
101 var url="https://min-api.cryptocompare.com/data/pricemultifull?fsyms=" + coin_token + "&tsyms=USD&api_key=" + apiKey
102 var requestOptions = {
103 method: 'GET',
104 json: true,
105 gzip: true
106 };
107
108 var httpRequest= UrlFetchApp.fetch(url, requestOptions);
109 var getContext= httpRequest.getContentText();
110
111 var parseData=JSON.parse(getContext);
112 var resultdata = "https://www.cryptocompare.com" + parseData.RAW[coin_token].USD.IMAGEURL;
113 return resultdata;
114}
115
116function getTotalSupply(coin_token) {
117 //Make sure that you got the API key from Coinmarketcap API dashboard and paste it in sheet_1 on cell B1
118 //var apiKey=sh1.getRange(1, 2).getValue();
119 var apiKey = "APIKEY"
120 //var coin_token = "BNB"
121
122 var url="https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=" + coin_token
123 var requestOptions = {
124 method: 'GET',
125 uri: 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest',
126 qs: {
127 start: 1,
128 limit: 5000,
129 convert: 'USD'
130 },
131 headers: {
132 'X-CMC_PRO_API_KEY': apiKey
133 },
134 json: true,
135 gzip: true
136 };
137
138 var httpRequest= UrlFetchApp.fetch(url, requestOptions);
139 var getContext= httpRequest.getContentText();
140
141 var parseData=JSON.parse(getContext);
142 var maxsupply = parseData.data[coin_token].max_supply;
143 return maxsupply;
144}
145
146function getCirculatingSupply(coin_token) {
147 //Make sure that you got the API key from Coinmarketcap API dashboard and paste it in sheet_1 on cell B1
148 //var apiKey=sh1.getRange(1, 2).getValue();
149 var apiKey = "APIKEY"
150 //var coin_token = "BNB"
151
152 var url="https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=" + coin_token
153 var requestOptions = {
154 method: 'GET',
155 uri: 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest',
156 qs: {
157 start: 1,
158 limit: 5000,
159 convert: 'USD'
160 },
161 headers: {
162 'X-CMC_PRO_API_KEY': apiKey
163 },
164 json: true,
165 gzip: true
166 };
167
168 var httpRequest= UrlFetchApp.fetch(url, requestOptions);
169 var getContext= httpRequest.getContentText();
170
171 var parseData=JSON.parse(getContext);
172 var circulatingsupply = parseData.data[coin_token].circulating_supply;
173 return circulatingsupply;
174}
175
176function getPortfolioData(){
177 // Use a for-loop to add all numbers from 1 to N to the array output.
178 //for(var i = 1; i <= value; i++) {
179// output.push(i);
180// }
181
182 // Finally we return the array output.
183 //return output;
184
185
186
187 //Make sure that you got the API key from Coinmarketcap API dashboard and paste it in sheet_1 on cell B1
188 //var apiKey=sh1.getRange(1, 2).getValue();
189 var apiKey = "Basic APIKEY"
190 //var coin_token = "BNB"
191
192 var url="https://hooks.dashblock.com/v1/project/APIKEY/1.0.0/skill"
193 var requestOptions = {
194 method: 'POST',
195 headers: {
196 'Authorization': apiKey
197 },
198 json: true,
199 gzip: true
200 };
201
202 var httpRequest= UrlFetchApp.fetch(url, requestOptions);
203 var getContext= httpRequest.getContentText();
204
205 var parseData=JSON.parse(getContext);
206
207 // var output = [];
208 //var outputCoinPercentage = [];
209 var coins = [];
210
211 for(var i = 0; i <= parseData.length - 1; i++){
212 var CoinPortfolio = parseData[i].Coin;
213 var CoinPercentage = parseData[i].PortfolioPercentage;
214
215 //console.log(CoinPortfolio);
216 //console.log(CoinPercentage);
217 //coins[i] = new Array(2);
218 coins.push([CoinPortfolio,CoinPercentage]);
219 //coins[i][1]= CoinPortfolio;
220 //coins[i][2]= CoinPercentage;
221 //output.push(CoinPortfolio);
222 }
223
224 //var portfolioData = parseData.data[coin_token].circulating_supply;
225 return coins;
226}
227
228function getCCprice(coin_token) {
229 //Make sure that you got the API key from Coinmarketcap API dashboard and paste it in sheet_1 on cell B1
230 //var apiKey=sh1.getRange(1, 2).getValue();
231 var apiKey = "APIKEY"
232 //var coin_token = "ETH"
233
234 var url="https://min-api.cryptocompare.com/data/price?fsym=" + coin_token + "&tsyms=USD&api_key=" + apiKey
235 var requestOptions = {
236 method: 'GET',
237 json: true,
238 gzip: true
239 };
240
241 var httpRequest= UrlFetchApp.fetch(url, requestOptions);
242 var getContext= httpRequest.getContentText();
243
244 var parseData=JSON.parse(getContext);
245 var resultdata = parseData.USD;
246 return resultdata;
247}
248
249function getCCMarketCap(coin_token) {
250 //Make sure that you got the API key from Coinmarketcap API dashboard and paste it in sheet_1 on cell B1
251 //var apiKey=sh1.getRange(1, 2).getValue();
252 var apiKey = "APIKEY"
253 //var coin_token = "ETH"
254
255 var url="https://min-api.cryptocompare.com/data/pricemultifull?fsyms=" + coin_token + "&tsyms=USD&api_key=" + apiKey
256 var requestOptions = {
257 method: 'GET',
258 json: true,
259 gzip: true
260 };
261
262 var httpRequest= UrlFetchApp.fetch(url, requestOptions);
263 var getContext= httpRequest.getContentText();
264
265 var parseData=JSON.parse(getContext);
266 var resultdata = parseData.RAW[coin_token].USD.MKTCAP;
267 return resultdata;
268}
269
270function getCCSupply(coin_token) {
271 //Make sure that you got the API key from Coinmarketcap API dashboard and paste it in sheet_1 on cell B1
272 //var apiKey=sh1.getRange(1, 2).getValue();
273 var apiKey = "APIKEY"
274 //var coin_token = "ETH"
275
276 var url="https://min-api.cryptocompare.com/data/pricemultifull?fsyms=" + coin_token + "&tsyms=USD&api_key=" + apiKey
277 var requestOptions = {
278 method: 'GET',
279 json: true,
280 gzip: true
281 };
282
283 var httpRequest= UrlFetchApp.fetch(url, requestOptions);
284 var getContext= httpRequest.getContentText();
285
286 var parseData=JSON.parse(getContext);
287 var resultdata = parseData.RAW[coin_token].USD.SUPPLY;
288 return resultdata;
289}
290
291function getCCSignals(coin_token) {
292 //Make sure that you got the API key from Coinmarketcap API dashboard and paste it in sheet_1 on cell B1
293 //var apiKey=sh1.getRange(1, 2).getValue();
294 var apiKey = "APIKEY"
295 //var coin_token = "ETH"
296
297 var url="https://min-api.cryptocompare.com/data/tradingsignals/intotheblock/latest?fsym=" + coin_token + "&api_key=" + apiKey
298 var requestOptions = {
299 method: 'GET',
300 json: true,
301 gzip: true
302 };
303
304 var httpRequest= UrlFetchApp.fetch(url, requestOptions);
305 var getContext= httpRequest.getContentText();
306
307 var parseData=JSON.parse(getContext);
308 var resultdata = parseData.Data.addressesNetGrowth.sentiment;
309 return resultdata;
310}