0

This question is not related to YQL / datatables.org claimed by some to be down a few days ago, as the YQL did respond in my case, but the problem lay in response character-set and hence decoding it. For other security symbols like GOOG, it used to respond perfectly.

This is the REST Query I am using to retrieve stock data for "AOJ-P.CO" from Yahoo finance API:

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quote%20where%20symbol%20in%20(%22AOJ-P.CO%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=

It gives following response:

{
 "query": {
  "count": 0,
  "created": "2017-05-18T06:54:16Z",
  "lang": "en-US",
  "diagnostics": {
   "url": [
    {
     "execution-start-time": "0",
     "execution-stop-time": "1",
     "execution-time": "1",
     "content": "http://www.datatables.org/yahoo/finance/quote/yahoo.finance.quote.xml"
    },
    {
     "execution-start-time": "5",
     "execution-stop-time": "6",
     "execution-time": "1",
     "content": "http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO"
    }
   ],
   "publiclyCallable": "true",
   "cache": {
    "execution-start-time": "3",
    "execution-stop-time": "4",
    "execution-time": "1",
    "method": "GET",
    "type": "MEMCACHED",
    "content": "5d1e1de680846a307c9874dc3d6878dc"
   },
   "warning": [
    "Unable to decode response content for http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO using utf-8",
    "Unable to find valid encoding for response content for http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO"
   ],
   "query": {
    "execution-start-time": "4",
    "execution-stop-time": "6",
    "execution-time": "2",
    "params": "{url=[http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO]}",
    "content": "select * from csv where url=@url and columns='Ask,AverageDailyVolume,Bid,AskRealtime,BidRealtime,BookValue,Change&PercentChange,Change,Commission,Currency,ChangeRealtime,AfterHoursChangeRealtime,DividendShare,LastTradeDate,TradeDate,EarningsShare,ErrorIndicationreturnedforsymbolchangedinvalid,EPSEstimateCurrentYear,EPSEstimateNextYear,EPSEstimateNextQuarter,DaysLow,DaysHigh,YearLow,YearHigh,HoldingsGainPercent,AnnualizedGain,HoldingsGain,HoldingsGainPercentRealtime,HoldingsGainRealtime,MoreInfo,OrderBookRealtime,MarketCapitalization,MarketCapRealtime,EBITDA,ChangeFromYearLow,PercentChangeFromYearLow,LastTradeRealtimeWithTime,ChangePercentRealtime,ChangeFromYearHigh,PercebtChangeFromYearHigh,LastTradeWithTime,LastTradePriceOnly,HighLimit,LowLimit,DaysRange,DaysRangeRealtime,FiftydayMovingAverage,TwoHundreddayMovingAverage,ChangeFromTwoHundreddayMovingAverage,PercentChangeFromTwoHundreddayMovingAverage,ChangeFromFiftydayMovingAverage,PercentChangeFromFiftydayMovingAverage,Name,Notes,Open,PreviousClose,PricePaid,ChangeinPercent,PriceSales,PriceBook,ExDividendDate,PERatio,DividendPayDate,PERatioRealtime,PEGRatio,PriceEPSEstimateCurrentYear,PriceEPSEstimateNextYear,Symbol,SharesOwned,ShortRatio,LastTradeTime,TickerTrend,OneyrTargetPrice,Volume,HoldingsValue,HoldingsValueRealtime,YearRange,DaysValueChange,DaysValueChangeRealtime,StockExchange,DividendYield'"
   },
   "javascript": {
    "execution-start-time": "3",
    "execution-stop-time": "6",
    "execution-time": "3",
    "instructions-used": "12000",
    "table-name": "yahoo.finance.quote"
   },
   "user-time": "6",
   "service-time": "3",
   "build-version": "2.0.118"
  },
  "results": null
 }
}

Basically this is to be noticed:

"warning": [
    "Unable to decode response content for http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO using utf-8",
    "Unable to find valid encoding for response content for http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO"
   ],

It says it is "Unable to decode response content using utf-8"

I am not sure what is wrong here, but this is a valid stock symbol, and should give results like this: https://in.finance.yahoo.com/quote/AOJ-P.CO?p=AOJ-P.CO

Guessing it is because of some special characters in the response, like one in it's name "Brødrene A & O Johansen A/S"?

It does however gives some result in the quotes.csv mentioned in the response: http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO

But how can I get valid response like other symbols (for eg "GOOG") for this symbol? What's wrong with this request?

Prashant
  • 5,331
  • 10
  • 44
  • 59
  • 1
    Possible duplicate of [Is YQL / datatables.org down as of May 17-18, 2017?](http://stackoverflow.com/questions/44050518/is-yql-datatables-org-down-as-of-may-17-18-2017) – kongeb May 18 '17 at 23:03
  • @kongeb Actually the YQL did provide response in my case, but the problem lay in response character-set and hence the problem decoding it. For other security symbols like GOOG, it used to respond perfectly. – Prashant May 22 '17 at 10:48

1 Answers1

0

Until I get another solution, I figured out it is better to read the quotes.csv from the response for the time being.

And this is a useful library: https://github.com/dirkolbrich/yahoo-finance-query

Demo: http://code.dirkolbrich.de/YahooFinanceQuery/

Prashant
  • 5,331
  • 10
  • 44
  • 59