I'm currently implementing the Alpha Vantage Api into a react-native app. What I want to do is get the closing price for each 15 minute time period. What I'm thinking might work is using a loop and storing each closing price into an array. But I'm confused as to how I would access that data.
This is what I currently do to get the current price and Symbol which works perfectly fine.
return fetch ('https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=MSFT&interval=15min&outputsize=full&apikey=demo')
.then((response) => response.json())
.then((responseJson) => {
// console.log(responseJson);
const lastRefreshed = responseJson['Meta Data']['3. Last Refreshed'];
this.setState({
tickerSymbol: responseJson['Meta Data']['2. Symbol'],
stockPrice: responseJson['Time Series (15min)'][lastRefreshed]['4. close']
}, function(){
});
})
.catch((error)=>{
console.error(error);
});
And this is what the Json response looks like.
{
"Meta Data": {
"1. Information": "Intraday (15min) prices and volumes",
"2. Symbol": "MSFT",
"3. Last Refreshed": "2018-03-20 16:00:00",
"4. Interval": "15min",
"5. Output Size": "Full size",
"6. Time Zone": "US/Eastern"
},
"Time Series (15min)": {
"2018-03-20 16:00:00": {
"1. open": "93.2650",
"2. high": "93.3000",
"3. low": "93.0900",
"4. close": "93.1300",
"5. volume": "3642086"
},
"2018-03-20 15:45:00": {
"1. open": "93.5949",
"2. high": "93.6200",
"3. low": "93.2700",
"4. close": "93.2700",
"5. volume": "890793"
},
"2018-03-20 15:30:00": {
"1. open": "93.5599",
"2. high": "93.6500",
"3. low": "93.4900",
"4. close": "93.5900",
"5. volume": "712366"
},
"2018-03-20 15:15:00": {
"1. open": "93.4700",
"2. high": "93.6390",
"3. low": "93.4600",
"4. close": "93.5550",
"5. volume": "825406"
},
"2018-03-20 15:00:00": {
"1. open": "93.4800",
"2. high": "93.5350",
"3. low": "93.3700",
"4. close": "93.4700",
"5. volume": "451393"
},
"2018-03-20 14:45:00": {
"1. open": "93.5300",
"2. high": "93.6000",
"3. low": "93.4100",
"4. close": "93.4900",
"5. volume": "534200"
}}}
Any help would be appreciated! Thanks!