PHPackages                             dirkolbrich/yahoo-finance-query - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. dirkolbrich/yahoo-finance-query

AbandonedArchivedLibrary[API Development](/categories/api)

dirkolbrich/yahoo-finance-query
===============================

A PHP class to query the Yahoo Finance API

v1.0.5(9y ago)261.3k13MITPHP

Since Sep 28Pushed 8y ago1 watchersCompare

[ Source](https://github.com/dirkolbrich/yahoo-finance-query)[ Packagist](https://packagist.org/packages/dirkolbrich/yahoo-finance-query)[ RSS](/packages/dirkolbrich-yahoo-finance-query/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (8)Used By (0)

*For your Information: This is an ***abandoned*** project.*

*As with Yahoo's latest API change (March 2017), and while I am moving more and more to Golang, I will no longer maintain this PHP package. Feel free to fork and make your own adjustments.*

*Thank you for your interest. I'll leave this files permanently for your and my documentation. The public available code example on my own webspace will be terminated.*

*My personal special ***Thank You*** goes to all contributors. You tought me a lot.*

---

YahooFinanceQuery
-----------------

[](#yahoofinancequery)

A PHP class to query the Yahoo Finance API.

### Features

[](#features)

- search for symbol via Yahoo.Finance.Symbol.AutoSuggest
- query current quotes for symbols
- query historical quotes for single symbol
- query intraday quotes for single symbol
- query basic stock info
- query list of related stocks for index symbols
- query full list of sectors with related industries

### Example

[](#example)

You can find an example.php file under `/example`.

### Installation

[](#installation)

require via `composer.json` in your project root

```
{
    "require": {
        "dirkolbrich/yahoo-finance-query": "dev-master"
    }
}
```

### Implementation

[](#implementation)

As simple as that:

```
use DirkOlbrich\YahooFinanceQuery\YahooFinanceQuery;
// [...]
$query = new YahooFinanceQuery;
```

or as static:

```
use DirkOlbrich\YahooFinanceQuery\YahooFinanceQuery;
// [...]
YahooFinanceQuery->make();
```

### Configuration

[](#configuration)

YahooFinanceQuery can be configured to return the data as an array or the raw json. Default `returnType` is `array`.

The config setting has to be passed as an array `array('returnType' => 'array')` or `array('returnType' => 'json')`.

At initialisation:

```
$query = new YahooFinanceQuery(array('returnType' => 'json'));
```

or as static:

```
YahooFinanceQuery->make(array('returnType' => 'json'));
```

At run-time:

```
$query = new YahooFinanceQuery;
$query->config(array('returnType' => 'json'));
```

The current config setting can be retrieved with:

```
$query->getConfig();
```

To retrieve the raw cURL result use `raw()` as addition to the query. This method must be called before the actural query method.

```
$query->raw()->quote()->get();
```

To force the query via the YQL api (if possible), use the `yql()` method within the query string. This method must be called before the actural query method. The default is set to not use YQL, as I think YQL querys are unreliable and often with truncated results.

```
$query->yql()->quote()->get();
```

### Usage

[](#usage)

Querys are chainable. Use the `get()` method to to retrieve the results.

```
$data = $query->method()->get();
```

The following query methods are available:

1. `symbolSuggest($string)`

    Query for symbol suggestion via the YAHOO.Finance.SymbolSuggest.ssCallback

    ```
    $string = 'basf';
    $data = $query->symbolSuggest($string)->get();
    ```
2. `quote(array $symbol [, array $params])`

    Query for current quote for given symbols and given parameters.

    The passed parameter `$symbol` must be an array. Several symbols can be passed.

    The passed parameter `$params` is optional and must be an array too. It accepts the parameters as a written word or as tags. See as reference the `$quoteParams` variable in the class definition. If `$params` is empty, the query will use all possible params.

    The params 'Symbol', 'LastTradeTime' and 'LastTradeDate' will be quered by default. There will be a unified UTC 'LastTradeTimestamp' added to the result array.

    ```
    $symbol = array('bas.de');
    $params = array('LastTradePriceOnly', 'x', 'c1');
    $data = $query->quote($symbol, $params)->get();
    ```
3. `historicalQuote(array $symbol [, $startDate, $endDate, $param])`

    Query for historical quotes for given symbol with given start date and end date.

    Only one `$symbol` can be passed per query and must be a string.

    `$startDate` and `$endDate` must be in the format YYYY-MM-DD. If no dates are passed, the query will grab all available historical quotes. If only one date is passed, the other one will be set to the maximum available.

    `$param` is set to default `d` = daily. See `$historicalQuoteParams` variable for other options.

    ```
    $symbol = array('bas.de');
    $startDate = 2013-07-26;
    $endDate = 2014-01-06;
    $param = 'd';
    $data = $query->historicalQuote($symbol, $startDate, $endDate, $param)->get();
    ```

    I recommend not to use the `yql()` method with historical quotes, as the YQL console permits only up to 365 single result quotes. To retrieve a full set of historical quotes will not be possible via YQL.
4. `intraDay($symbol [, $period, $param])`

    Query finance.yahoo.com for intraday quotes. The symbol must be passed as as string.

    `$period` is optional and default set to `1d`. It is possible to retrieve intraday quotes for up to the last 15 days.

    `$param` is optional and default set to `quote`. For other options see the `$intraDayParams` variable.

    ```
    $symbol = 'bas.de';
    $period = '5d';
    $data = $query->intraDay($symbol, $period)->get();
    ```
5. `stockInfo($symbol)`

    Query finance.yahoo.com for basic stock information. The symbol must be passed as as string.

    ```
    $symbol = 'bas.de';
    $data = $query->stockInfo($symbol)->get();
    ```
6. `indexList(array $symbol)`

    Query for an index which returns the symbol and name of the components. Several symbols may be passed as an array.

    See  for more symbols to world indices. The caret `^` character must be part of the symbol.

    ```
    $symbol = array('^GDAXI');
    $data = $query->indexList($symbol)->get();
    ```
7. `sectorList()`

    Query for a complete list of sectors and their corresponding industries.

    This function is static without any params.

    ```
    $data = $query->sectorList()->get();
    ```

    Which returns an array in this form:

    ```
    Array (
        [0] => Array (
            [name] => Basic Materials
            [industries] => Array (
                [0] => Array (
                    [name] => Agricultural Chemicals
                    [id] => 112 )
                [1] => Array (
                    [name] => Aluminum
                    [id] => 132 )
                ... )
            )
        [1] => Array (
            [name] => Conglomerates
            [industries] => Array ( ... )
            )
    )
    ```

### Recources

[](#recources)

Some informative blog post and websites:

Yahoo YQL homepage

-

Blog post on that matter

-

Blog post from Joseph D. Purcell with an overview over finance API'S is a good entry point

-

[www.gummy-stuff.org](http://www.gummy-stuff.org) explains the Yahoo Finance .csv API

- Update on this: Yahoo harrased Mr. Ponzo about his documentation of a publicy available API and claimed some infringement on their TOS. But thanks to the internet archive, the last snapshot of this site is available at

An overview over different api endpoints by Matthias Brusdeylins (german)

-

Tutorial for the YQL console by Thomas Belser (german)

-

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 91.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~78 days

Recently: every ~98 days

Total

6

Last Release

3487d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3765119?v=4)[Dirk Olbrich](/maintainers/dirkolbrich)[@dirkolbrich](https://github.com/dirkolbrich)

---

Top Contributors

[![dirkolbrich](https://avatars.githubusercontent.com/u/3765119?v=4)](https://github.com/dirkolbrich "dirkolbrich (65 commits)")[![leihog](https://avatars.githubusercontent.com/u/385317?v=4)](https://github.com/leihog "leihog (3 commits)")[![ihr-it-projekt](https://avatars.githubusercontent.com/u/6061274?v=4)](https://github.com/ihr-it-projekt "ihr-it-projekt (2 commits)")[![jimitit](https://avatars.githubusercontent.com/u/5569914?v=4)](https://github.com/jimitit "jimitit (1 commits)")

---

Tags

financeyahoo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dirkolbrich-yahoo-finance-query/health.svg)

```
[![Health](https://phpackages.com/badges/dirkolbrich-yahoo-finance-query/health.svg)](https://phpackages.com/packages/dirkolbrich-yahoo-finance-query)
```

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[scheb/yahoo-finance-api

PHP library for accessing Yahoo Finance data

318204.8k5](/packages/scheb-yahoo-finance-api)[bunq/sdk_php

bunq PHP SDK

89222.7k2](/packages/bunq-sdk-php)[jeffreyhyer/alpaca-trade-api-php

PHP SDK for the Alpaca trade API

285.0k](/packages/jeffreyhyer-alpaca-trade-api-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
