1

I am trying to get data from Yahoo Finance via the Webservices. I want to query this source. When i put this into my browsers address bar then everything works fine:

url:

http://finance.yahoo.com/webservice/v1/symbols/DAI.DE,ALIK16.CMX/quote?format=json

result:

{
  "list": {
    "meta": {
      "type": "resource-list",
      "start": 0,
      "count": 2
    },
    "resources": [
      {
        "resource": {
          "classname": "Quote",
          "fields": {
            "name": "DAIMLER N",
            "price": "54.439999",
            "symbol": "DAI.DE",
            "ts": "1467029449",
            "type": "equity",
            "utctime": "2016-06-27T12:10:49+0000",
            "volume": "3990557"
          }
        }
      },
      {
        "resource": {
          "classname": "Quote",
          "fields": {
            "name": "Aluminum Futures,May-2016",
            "price": "1600.250000",
            "symbol": "ALIK16.CMX",
            "ts": "1464022420",
            "type": "future",
            "utctime": "2016-05-23T16:53:40+0000",
            "volume": "3"
          }
        }
      }
    ]
  }
}

When i try to implement this qith jQuery within a simple HTML page i always get an error 406. I am searching now for hours without any solution. What am i doing wrong?

This is my HTML page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Ohne_Titel_1</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">

$.ajax({
  url: "http://finance.yahoo.com/webservice/v1/symbols/DAI.DE,ALIK16.CMX/quote?format=json",
  dataType: 'jsonp',  //use jsonp data type in order to perform cross domain ajax
  crossDomain: true,
    success: function(json) {
    console.log(" reponse :"+ json);
    },error: function (XMLHttpRequest, textStatus, errorThrown) {
    console.log("error :"+XMLHttpRequest.responseText);
    }
});

</script>
</head>

<body>
    <div id='dvStockTicker' class='stockTicker'></div>
</body>

</html>
STORM
  • 4,005
  • 11
  • 49
  • 98
  • I have also tried to add acceptance header like ` accepts: { json: 'application/json', xml: 'application/xml' },` but this also doesnt work. – STORM Jun 28 '16 at 05:55

1 Answers1

0

This is an old question, but just in case you stumbled here: Seems Yahoo changed who the usage terms for this API. Seems to be permissible from phones only, not from desktop. For a workaround, see: Has Yahoo finance web service disappeared? API changed? Down temporarily?

Community
  • 1
  • 1