No definition found for Table yahoo.finance.xchange
Asked Answered
M

5

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.

Maestricht answered 24/8, 2017 at 8:54 Comment(9)
Have same issue any news?Welford
Almost exactly same issue here.. I'm trying to fetch rss-feed. It has worked flawlessly till now. Bump on the "any news?".Villalba
looks like they just killed this API. unbelievable.Maestricht
User Eduardo Cezarino posted this i.sstatic.net/0vEZ2.png on a similar thread.Inhaler
meanwhile, I switched my service to grab data from a European Cetral Bank fixer.io. It provides a limited currency list. At least something.Maestricht
Have same issue here. Any suggestion or replacement?Disgraceful
@PhucVuong check out my blog post - ayastreb.me/currency-exchange-microservice-with-webtask - I've written a microservice to provide currency exchange ratesConnect
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 ?Valerivaleria
Looks like this Yahoo Currency Converter API is being discontinued : #47072764Filip
M
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.

Mease answered 24/8, 2017 at 23:58 Comment(2)
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.Fop
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.Disafforest
A
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;
}
Aleishaalejandra answered 30/8, 2017 at 23:53 Comment(1)
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."Ky
A
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;
        }
    }
Aundrea answered 1/9, 2017 at 14:10 Comment(0)
C
-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 😉

Connect answered 30/8, 2017 at 7:37 Comment(0)
D
-3

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

Disgraceful answered 25/8, 2017 at 10:50 Comment(1)
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.Maestricht

© 2022 - 2024 — McMap. All rights reserved.