• Stars
    star
    278
  • Rank 148,454 (Top 3 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 11 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PHP client for Yahoo Finance API 📈

scheb/yahoo-finance-api

This is a PHP client for Yahoo Finance API.

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads License

Logo

Since YQL APIs have been discontinued in November 2017, this client is using non-official API endpoints for quotes, search and historical data.

⚠ïļ WARNING: These non-official APIs cannot be assumed stable and might break any time. Also, you might violate Yahoo's terms of service. So use them at your own risk.

Installation

Download via Composer:

composer require scheb/yahoo-finance-api

Alternatively you can also add the package directly to composer.json:

{
    "require": {
        "scheb/yahoo-finance-api": "^4.0"
    }
}

and then tell Composer to install the package:

composer update scheb/yahoo-finance-api

Usage

use Scheb\YahooFinanceApi\ApiClient;
use Scheb\YahooFinanceApi\ApiClientFactory;
use GuzzleHttp\Client;

// Create a new client from the factory
$client = ApiClientFactory::createApiClient();

// Or use your own Guzzle client and pass it in
$options = [/* ... */];
$guzzleClient = new Client($options);
$client = ApiClientFactory::createApiClient($guzzleClient);

// Returns an array of Scheb\YahooFinanceApi\Results\SearchResult
$searchResult = $client->search("Apple");

// Returns an array of Scheb\YahooFinanceApi\Results\HistoricalData
$historicalData = $client->getHistoricalQuoteData(
    "AAPL",
    ApiClient::INTERVAL_1_DAY,
    new \DateTime("-14 days"),
    new \DateTime("today")
);

// Retrieve dividends history, returns an array of Scheb\YahooFinanceApi\Results\DividendData
$dividendData = $client->getHistoricalDividendData(
    "AAPL",
    new \DateTime("-5 years"),
    new \DateTime("today")
);

// Retrieve stock split history, returns an array of Scheb\YahooFinanceApi\Results\SplitData
$splitData = $client->getHistoricalSplitData(
    "AAPL",
    new \DateTime("-5 years"),
    new \DateTime("today")
);

// Returns Scheb\YahooFinanceApi\Results\Quote
$exchangeRate = $client->getExchangeRate("USD", "EUR");

// Returns an array of Scheb\YahooFinanceApi\Results\Quote
$exchangeRates = $client->getExchangeRates([
    ["USD", "EUR"],
    ["EUR", "USD"],
]);

// Returns Scheb\YahooFinanceApi\Results\Quote
$quote = $client->getQuote("AAPL");

// Returns an array of Scheb\YahooFinanceApi\Results\Quote
$quotes = $client->getQuotes(["AAPL", "GOOG"]);

Version Guidance

Version Status PHP Version
1.x EOL >= 5.3.0
2.x EOL >= 5.6.0
3.x EOL >= 5.6.0
4.x Maintained >= 7.1.3

License

This library is available under the MIT license.

Contributing

Want to contribute to this project? See CONTRIBUTING.md.

Support Me

I'm developing this library since 2014. I love to hear from people using it, giving me the motivation to keep working on my open source projects.

If you want to let me know you're finding it useful, please consider giving it a star ⭐ on GitHub.

If you love my work and want to say thank you, you can help me out for a beer ðŸŧïļ via PayPal.

More Repositories

1

2fa

Two-factor authentication for Symfony applications 🔐
PHP
500
star
2

two-factor-bundle

[ABANDONED] Two-factor authentication for Symfony 2 & 3 applications 🔐. Please use the newer versions from https://github.com/scheb/2fa.
PHP
385
star
3

tombstone

Dead code detection with tombstones for PHP ðŸŠĶ🧟
PHP
260
star
4

sound-to-light-osc

Real-time detection of beats from audio, sending out OSC signals for sound-to-light control ðŸŽĩðŸ’Ą
Python
71
star
5

2fa-bundle

[READ ONLY] A generic interface to implement two-factor authentication in Symfony applications
PHP
59
star
6

beer-analytics

Analyzing the composition of beer recipes and visualize results in a human-friendly way ðŸ•ĩïļðŸš
Python
41
star
7

2fa-trusted-device

[READ ONLY] Extends scheb/2fa-bundle with trusted devices support
PHP
31
star
8

2fa-email

[READ ONLY] Extends scheb/2fa-bundle with two-factor authentication via email
PHP
29
star
9

tombstone-analyzer

[READ ONLY] Report generation for Tombstones created with the scheb/tombstone-logger library
PHP
28
star
10

2fa-google-authenticator

[READ ONLY] Extends scheb/2fa-bundle with two-factor authentication using Google Authenticator
PHP
23
star
11

2fa-totp

[READ ONLY] Extends scheb/2fa-bundle with two-factor authentication using TOTP
PHP
21
star
12

2fa-backup-code

[READ ONLY] Extends scheb/2fa-bundle with backup codes support
PHP
18
star
13

open-apexx

[INACTIVE] ☠ïļ Open source distribution of apexx CMS
PHP
12
star
14

stock-panel

Symfony application to keep track of your stock portfolio 📈
PHP
11
star
15

2fa-qr-code

[READ ONLY] Extends scheb/2fa-bundle to render QR codes
PHP
9
star
16

in-memory-data-storage

A simple in-memory data storage for PHP
PHP
9
star
17

stock-panel-bundle

[DEPRECATED] Keep track of your stock portfolio
PHP
6
star
18

beer-recipe-analysis

Analyzing the composition of beer brewing recipes with Python and Pandas. It's now a website: www.beer-analytics.com
Jupyter Notebook
3
star
19

phpunit-non-deterministic

How to stub non-deterministic dependencies
PHP
2
star
20

party-projector

Display messages and pictures from party guests on a projector screen
Java
2
star
21

tombstone-logger

[READ ONLY] Tracking of tombstones to find dead code in your codebase
PHP
2
star
22

property-access

Read and write properties from/to PHP objects and arrays
PHP
2
star
23

implementation-iterator

Iterates a PSR-4 compliant directory for implementations of a class/interface
PHP
2
star
24

idea-inspections-checkstyle-converter

[DEPRECATED] Convert IDEA (IntelliJ, PHPStorm) inspection XML format to checkstyle
PHP
2
star
25

two-factor-app

[DEPRECATED] Test application for scheb/two-factor-bundle
PHP
2
star
26

comparator

Answer the question "Are these two equal values?"
PHP
2
star
27

tombstone-core

[READ ONLY] Core classes of the scheb/tombstone library
PHP
2
star
28

qlc-generator

Scripts to generate QLC+ scenes and sequences
PHP
2
star
29

party-projector-app

Android app for scheb/party-projector
Java
1
star
30

mogilefs-stubs

IDE stubs for MogileFS extension
PHP
1
star
31

idea-inspections-core

[DEPRECATED] Core classes to process IDEA inspection files
PHP
1
star