Search code examples
phpyqlyahoo-api

YQL request returning Connection refused


The following PHP code (on Laravel) has been working for months until today, where I am now receiving a 502 error indicating connection refused:

$url = "https://query.yahooapis.com/v1/public/yql?q=select+%2A+from+yahoo.finance.quotes+where+symbol+in+%28%27YHOO%27%29&format=json&env=%20store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=";

$data = file_get_contents($url);
dd($data);

When I login to the Yahoo Developer Console to test, I'm able to query the public datatables just fine. However, when I attempt to use the console to access any of the community datatables like this, I am returned the following (this error occurs with all community datatables):

{
 "error": {
  "lang": "en-US",
  "diagnostics": {
   "url": {
    "execution-start-time": "0",
    "execution-stop-time": "7",
    "execution-time": "7",
    "http-status-code": "502",
    "http-status-message": "Connection refused",
    "content": "http://www.datatables.org/yahoo/finance/yahoo.finance.quotes.xml"
   }
  },
  "description": "No definition found for Table yahoo.finance.quotes"
 }
}

Using a different machine/IP address, I am able to access these community tables just fine as long as I remain anonymous. Once I login to the Yahoo Developer Console, the Connection refused message appears again.

I suspect it has something to do with Yahoo possibly blacklisting my IP address or throttling my account as I run this script for every stock (3,000) once per day.

I attempted to access the URL referenced in the error message content node and it appears this site is down. I'm not sure if this content node matters to the API, as I am able to access it from a different IP address.

I'm open to suggestions and recommendations on how I can determine/fix this problem.


Solution

  • Yahoo Community tables are stored in datatables.org, and datatables.org is down; that's why there's a querying problem.

    http://www.datatables.org