Created
January 11, 2024 12:24
-
-
Save Hiutaky/4f12441c2929f6c3582ef61a7f6a2095 to your computer and use it in GitHub Desktop.
Google Sheet Crypto Price Fetch via KuCoin API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| Paste this script in Google Apps Script, will be available as function in Sheet by using =fetchPrice('SYMBOL') ex =fetchPrice('BTC') | |
| If you want to auto-update the price every time your open the Sheet, in Apps Script click on Triggers and add a new trigger | |
| Select the behavior you prefer and save. | |
| */ | |
| function fetchPrice(symbol = 'BTC') { | |
| const res = UrlFetchApp.fetch(`https://api.kucoin.com/api/v1/market/stats?symbol=${symbol}-USDT`); | |
| const obj = JSON.parse(res.getContentText()); | |
| return parseFloat(obj.data.buy) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment