I'm currently working on integrating a basic Stock API into JSFiddle.net using the Quandl API:
When I use the current format of ".csv"
as shown below, I receive a CSV file. However, if I switch the format to ".json"
in my API, how can I retrieve the data and effectively implement it on a website?
I believe I need to utilize a getJSON
command, but I am struggling to understand its functionality. Does anyone have guidance on this?
Here's the HTML:
<input type="text" id="symbol">
<button id="getPrice">Get Price!</button>
<div id="result">Stock Market Ticker</div>
JavaScript code:
function getPrice() {
var symbol = $("#symbol").val();
var baseurl = "https://www.quandl.com/api/v3/datasets/WIKI/";
var stock = symbol+".csv";
var endurl = "column_index=4&rows=1&api_key='8mii36sd1q46uLgSTkLm";
var url = baseurl+ stock + "?" + endurl;
$("#result ").html("<a href = '" + url + "' >Hyperlink</a>");
}
$("#getPrice ").click(getPrice);
By querying the stock ticker KORS (.CSV file), I obtain this output: Data Close 1/5/2016 40.72