Created
December 13, 2019 15:07
-
-
Save ShellyShulei/7070cf7d620b411fae9412784211c4ac to your computer and use it in GitHub Desktop.
Calls the GitHub API to get the star count for an org/user and repository.
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
| name: StockOnline (1) | |
| description: Calls the GitHub API to get the star count for an org/user and repository. | |
| host: EXCEL | |
| api_set: {} | |
| script: | |
| content: | | |
| /** | |
| * Gets the stock price online. Try =getStockOnline("FB") | |
| * @customfunction | |
| * @param symbol | |
| */ | |
| async function getStockOnline(symbol) { | |
| var API_KEY = "8KOBOUBTEF7RHR21"; | |
| const requestURL = `https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=${symbol}&apikey=${API_KEY}`; | |
| const response = await fetch(requestURL); | |
| const data = await response.json(); | |
| if (data.hasOwnProperty("Note")) { | |
| throw new Error("API limit reached"); | |
| } | |
| if (data.hasOwnProperty("Error Message")) { | |
| throw new Error(data["Error Message"]); | |
| } | |
| let monthlyData = data["Monthly Time Series"]; | |
| let dates = Object.keys(monthlyData); | |
| let a = data["Monthly Time Series"][dates[0]]["1. open"]; | |
| //let a = dates.forEach(function(item) { | |
| //console.log(dates[0]); | |
| console.log(a); | |
| console.log(requestURL); | |
| return a; | |
| //console.log(["Monthly Time Series"][item]["1. open"]); | |
| //}); | |
| } | |
| language: typescript | |
| libraries: | | |
| https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
| @types/office-js | |
| core-js@2.4.1/client/core.min.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment