12

I have a service which uses a Yahoo! Finance table yahoo.finance.xchange. This morning I noticed it has stopped working because suddenly Yahoo! started to return an error saying:

{
    "error": {
    "lang": "en-US",
        "description": "No definition found for Table yahoo.finance.xchange"
    }
}

This is the request URL. Interesting fact: if I try to refresh the query multiple times, sometimes I get back a correct response but this happen very rarely (like 10% of the time). Days before, everything was fine.

Does this mean Yahoo API is down or am I missing something because the API was changed? I would appreciate any help.

jeteon
  • 3,471
  • 27
  • 40
DolceVita
  • 2,090
  • 1
  • 23
  • 35
  • Have same issue any news? – Bukashk0zzz Aug 24 '17 at 09:19
  • Almost exactly same issue here.. I'm trying to fetch rss-feed. It has worked flawlessly till now. Bump on the "any news?". – MikkoS Aug 24 '17 at 13:15
  • 1
    looks like they just killed this API. unbelievable. – DolceVita Aug 24 '17 at 18:47
  • 1
    User Eduardo Cezarino posted this https://i.stack.imgur.com/0vEZ2.png on a similar thread. – DanielZ Aug 25 '17 at 06:35
  • 1
    meanwhile, I switched my service to grab data from a European Cetral Bank http://fixer.io/. It provides a limited currency list. At least something. – DolceVita Aug 25 '17 at 07:07
  • Have same issue here. Any suggestion or replacement? – Phuc Vuong Aug 25 '17 at 10:09
  • @PhucVuong check out my blog post - https://ayastreb.me/currency-exchange-microservice-with-webtask/ - I've written a microservice to provide currency exchange rates – a.yastreb Aug 30 '17 at 07:39
  • same issue here from couple of days and very seldom I get a success rate of around 5 percent only. any quick alternatives you have found ? – user2695433 Oct 13 '17 at 05:15
  • Looks like this Yahoo Currency Converter API is being discontinued : https://stackoverflow.com/questions/47072264/https-query-yahooapis-com-v1-public-yqlq-select-from-yahoo-finance-xchange/47100796#47100796 – rrudland Nov 03 '17 at 16:54

5 Answers5

3

Since I have the same problem and that it started today too, that others came to post exactly in the same time as well, and that it still works most of the time, the only explanation I can find is that they have some random database errors on their end and we can hope that this will be solved soon. I also have a 20% rate of failures when refreshing the page of the query.

My guess is that they use many servers to handle the requests (let's say 8) and that one of them is empty or doesn't have that table for some reasons so whenever it directs the query to that server, the error is returned.

Temporary solution: Just modify your script to retry 3-4 times. That did it for me because among 5 attempts at least one succeeds.

FlorianB
  • 2,188
  • 18
  • 30
  • I share similar theory. Since this affects end-users, I would assume there will be twitter feeds from Yahoo! telling us about this. I found none. – Phil Aug 29 '17 at 16:37
  • yep, this solution is not bad actually. And I would leave it as permanent. I do max 10 times retry and if it fails all the time, I fallback on one day old backup. Backup can be either in-memory or serialized into some file or DB and deserialized on fallback. I never had trust for Yahoo. – walv Aug 31 '17 at 01:42
1

I solve this issue by using quote.yahoo.com instead of the query.yahooapis.com service. Here's my code:

function devise($currency_from,$currency_to,$amount_from){
  $url = "http://quote.yahoo.com/d/quotes.csv?s=" . $currency_from . $currency_to . "=X" . "&f=l1&e=.csv";
  $handle  = fopen($url, "r");
  $exchange_rate = fread($handle, 2000);
  fclose($handle );
  $amount_to = $amount_from  * $exchange_rate;
  return round($amount_to,2);
}

EDIT the above no longer works. At this point, lets just forget about yahoo lol Use this instead

function convertCurrency($from, $to, $amount)    
{
    $url = file_get_contents('https://free.currencyconverterapi.com/api/v5/convert?q=' . $from . '_' . $to . '&compact=ultra');
    $json = json_decode($url, true);
    $rate = implode(" ",$json);
    $total = $rate * $amount;
    $rounded = round($total);
    return $total;
}
Patrick Simard
  • 2,294
  • 3
  • 24
  • 38
  • Tried this. Got the response that yahoo shut down that API as it has been used against their ToS: "It has come to our attention that this service is being used in violation of the Yahoo Terms of Service. As such, the service is being discontinued. For all future markets and equities data research, please refer to finance.yahoo.com." – DocRattie Nov 06 '17 at 09:49
0

Same error, i migrate to http://finance.yahoo.com Here is C# example

private static readonly ILog Log = LogManager.GetCurrentClassLogger();
    private int YahooTimeOut = 4000;
    private int Try { get; set; }

    public decimal GetRate(string from, string to)
    {
        var url =
            string.Format(
                "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s={0}{1}=X", from, to);

        var request = (HttpWebRequest)WebRequest.Create(url);
        request.UseDefaultCredentials = true;
        request.ContentType = "text/csv";
        request.Timeout = YahooTimeOut;
        try
        {
            using (var response = (HttpWebResponse)request.GetResponse())
            {
                var resStream = response.GetResponseStream();
                using (var reader = new StreamReader(resStream))
                {
                    var html = reader.ReadToEnd();
                    var values = Regex.Split(html, ",");
                    var rate = Convert.ToDecimal(values[1], new CultureInfo("en-US"));
                    if (rate == 0)
                    {
                        Thread.Sleep(550);
                        ++Try;
                        return Try < 5 ? GetRate(from, to) : 0;
                    }
                    return rate;

                }
            }
        }
        catch (Exception ex)
        {
            Log.Warning("Get currency rate from Yahoo fail " + ex);
            Thread.Sleep(550);
            ++Try;
            return Try < 5 ? GetRate(from, to) : 0;
        }
    }
-1

I've got the same issue.

I need exchange rates in my app, so I decided to use currencylayer.com API instead - they give 168 currencies, including precious metals and Bitcoin.

I've also written a microservice using webtask.io to cache rates from currencylayer and do cross-rate calculations.

And I've written a blog post about it

Check it out if you want to run your own microservice, it's pretty easy

a.yastreb
  • 1,493
  • 1
  • 10
  • 11
-3

I found solution, in my case, just change http to https and everything works fine.

Phuc Vuong
  • 150
  • 7
  • First of all, in my post I provided the url with https schema. Secondly - no, it does not work, It works randomly. 80% requests are refused. – DolceVita Aug 25 '17 at 13:09