Yahoo Finance All Currencies quote API Documentation

前端 未结 6 781
梦谈多话
梦谈多话 2020-12-02 09:51

I\'ve being using this feed for a long time, I believe Apple does it as well in one of the mac widgets. but what is really curious is that I simply can\'t find any documenta

6条回答
  •  日久生厌
    2020-12-02 10:45

    I have used this URL to obtain multiple currency market quotes.

    http://finance.yahoo.com/d/quotes.csv?e=.csv&f=c4l1&s=USD=X,CAD=X,EUR=X

    "USD",1.0000
    "CAD",1.2458
    "EUR",0.8396
    

    They can be parsed in PHP like this:

    $symbols = ['USD=X', 'CAD=X', 'EUR=X'];
    $url = "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=c4l1&s=".join($symbols, ',');
    
    $quote = array_map( 'str_getcsv', file($url) );
    
    foreach ($quote as $key => $symb) {
        $symbol = $quote[$key][0];
        $value = $quote[$key][1];
    }
    

提交回复
热议问题