问题
I'm using C# and I want to know how to use the Quandl API to get data via xml, like a stock price. I've never used an API before so I'm really lost. I was looking at their quick start guide, but I don't understand how something like "https://www.quandl.com/api/v3/datasets/WIKI/FB.xml" gets you anything. How do I make the API work? Can I even do it with C#?
回答1:
With javascript you'd rather use the json format of your chosen dataset: https://www.quandl.com/api/v3/datasets/WIKI/FB.json, instead of https://www.quandl.com/api/v3/datasets/WIKI/FB.xml. Then write a classical XMLHttpRequest:
var url = "https://www.quandl.com/api/v3/datasets/WIKI/FB.json";
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onload = function() {
var data = JSON.parse(this.responseText).dataset.data;
// {}.dataset.data is the data matrix in Quandl
// then process your own way
}
xhr.send();
来源:https://stackoverflow.com/questions/35003290/how-do-i-use-the-quandl-api