PHPackages                             marketdataapp/sdk-php - 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. marketdataapp/sdk-php

ActiveLibrary[API Development](/categories/api)

marketdataapp/sdk-php
=====================

PHP SDK for MarketData.app

v1.1.0(2mo ago)22.4k—0%[1 issues](https://github.com/MarketDataApp/sdk-php/issues)[1 PRs](https://github.com/MarketDataApp/sdk-php/pulls)MITPHPPHP ^8.2CI passing

Since Jul 8Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/MarketDataApp/sdk-php)[ Packagist](https://packagist.org/packages/marketdataapp/sdk-php)[ Docs](https://github.com/MarketDataApp/sdk-php)[ GitHub Sponsors](https://github.com/MarketDataApp)[ RSS](/packages/marketdataapp-sdk-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (19)Used By (0)

Market Data PHP SDK v1.1
========================

[](#market-data-php-sdk-v11)

### Access Financial Data with Ease

[](#access-financial-data-with-ease)

> This is the official PHP SDK for [Market Data](https://www.marketdata.app). It provides developers with a powerful, easy-to-use interface to obtain real-time and historical financial data. Ideal for building financial applications, trading bots, and investment strategies.

[![Latest Version on Packagist](https://camo.githubusercontent.com/3621fafa470a2292aec271cc4420944f10430829a8f9285bff30b7f0dc8b9fd4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f4d61726b6574446174614170702f73646b2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/MarketDataApp/sdk-php)[![Tests](https://camo.githubusercontent.com/3178ffe5eb17e19b929bf2d9b59556d2f5b24502532eaab1d8a3321792249b88/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4d61726b6574446174614170702f73646b2d7068702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/MarketDataApp/sdk-php/actions/workflows/run-tests.yml)[![Codecov](https://camo.githubusercontent.com/00c2151ee71e24c9292c54784f8bf8d970370ac97909fb1c50995aa8dd43926b/68747470733a2f2f636f6465636f762e696f2f67682f4d61726b6574446174614170702f73646b2d7068702f67726170682f62616467652e7376673f746f6b656e3d35573249423946365255)](https://codecov.io/github/MarketDataApp/sdk-php)[![Total Downloads](https://camo.githubusercontent.com/986139ecbae114ee7cf0c0af23de712588e20fb9604e5142516a900309f7655a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4d61726b6574446174614170702f73646b2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/MarketDataApp/sdk-php)[![PHP Version](https://camo.githubusercontent.com/4614a772dcc927b575a70d63e7ae3f926249d52eb5dc81d133a3631d11b7adf6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e32253230253743253230382e33253230253743253230382e34253230253743253230382e352d626c75652e7376673f7374796c653d666c61742d737175617265)](https://www.php.net/)

#### Connect With The Market Data Community

[](#connect-with-the-market-data-community)

[![Website](https://camo.githubusercontent.com/934722fbb849298584410f110e51aa2dc58dbbfb3d79e036025e7525bd3d79f8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f576562736974652d6d61726b6574646174612e6170702d626c7565)](https://www.marketdata.app/)[![Discord](https://camo.githubusercontent.com/6cd62302367866665850d1b47af4557b1ca70dd3f15ed208d6dc522c94997b68/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973636f72642d6a6f696e253230636861742d3733383944382e7376673f6c6f676f3d646973636f7264266c6f676f436f6c6f723d666666666666)](https://discord.com/invite/GmdeAVRtnT)[![Twitter](https://camo.githubusercontent.com/800686f9aea4031d1d01322f3106a61f0b66d904e0350b601a2d74d3a5e0f0fb/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f4d61726b6574446174614170703f7374796c653d736f6369616c)](https://twitter.com/MarketDataApp)[![Helpdesk](https://camo.githubusercontent.com/7456c3c7d010f49f85d5de84445e625105174eb2901010a0cc94e67a6465fc09/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f537570706f72742d5469636b6574696e672d6666363962342e7376673f6c6f676f3d5469636b65745461696c6f72266c6f676f436f6c6f723d7768697465)](https://www.marketdata.app/dashboard/)

Features
--------

[](#features)

- **Real-time Stock Data**: Prices, quotes, candles (OHLCV), earnings, and news
- **Options Trading Data**: Complete options chains, expirations, strikes, quotes, and lookup
- **Mutual Funds**: Historical candles and pricing data
- **Market Status**: Real-time market open/closed status for multiple countries
- **Multiple Output Formats**: JSON, CSV, or HTML formats
- **Built-in Retry Logic**: Automatic retry with exponential backoff for reliable data fetching
- **Rate Limit Tracking**: Automatic rate limit monitoring with easy access via `$client->rate_limits`
- **Type-Safe**: Full type hints and strict typing (PHP 8.2+)
- **Zero Config**: Works out of the box with sensible defaults

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require MarketDataApp/sdk-php
```

Configuration
-------------

[](#configuration)

The SDK requires a MarketData authentication token. You can provide it in two ways:

### Option 1: Environment variable (recommended)

[](#option-1-environment-variable-recommended)

Create a `.env` file in the project root:

```
MARKETDATA_TOKEN=your_token_here
```

Or set it as an environment variable:

```
export MARKETDATA_TOKEN=your_token_here
```

### Option 2: Pass token directly

[](#option-2-pass-token-directly)

You can pass the token when creating a client instance:

```
$client = new MarketDataApp\Client('your_token_here');
```

**Note:** If you provide a token explicitly, it will take precedence over environment variables.

Unsupported API features
------------------------

[](#unsupported-api-features)

The SDK intentionally does not support certain REST API options. These are design decisions, not oversights.

- **`token` query parameter** — The REST API may accept `token` as a query parameter. The SDK does not and will not support this. Authentication is sent only via the `Authorization: Bearer` header. This keeps tokens out of URLs (and thus out of logs, caches, and referrers) and centralizes auth in one place.
- **`limit` and `offset`** — The REST API supports `limit` and `offset` for pagination. The SDK does not and will not support these. The SDK uses concurrent parallel requests instead to fetch data in bulk, so limit/offset-style pagination is not part of the design.

Usage
-----

[](#usage)

```
// Token will be automatically obtained from MARKETDATA_TOKEN environment variable or .env file
$client = new MarketDataApp\Client();

// Or provide the token explicitly
$client = new MarketDataApp\Client('your_api_token');

// Stocks
$candles = $client->stocks->candles('AAPL');
$bulk_candles = $client->stocks->bulkCandles(['AAPL', 'MSFT']);
$quote = $client->stocks->quote('AAPL');
$quotes = $client->stocks->quotes(['AAPL', 'MSFT']);
$earnings = $client->stocks->earnings(symbol: 'AAPL', from: '2023-01-01');
$news = $client->stocks->news(symbol: 'AAPL', from: '2023-01-01');

// Markets
$status = $client->markets->status(date: '2023-01-01');

// Mutual Funds
$candles = $client->mutual_funds->candles(
    symbol: 'VFINX',
    from: '2022-09-01',
    to: '2022-09-05',
    resolution: 'D'
);

// Options
$expirations = $client->options->expirations('AAPL');
$lookup = $client->options->lookup('AAPL 7/28/23 $200 Call');
$strikes = $client->options->strikes(
    symbol: 'AAPL',
    expiration: '2023-01-20',
    date: '2023-01-03',
);
$option_chain = $client->options->option_chain(
    symbol: 'AAPL',
    expiration: '2028-12-15',
    side: Side::CALL,
);
$quotes = $client->options->quotes('AAPL281215C00400000');

// Utilities
$status = $client->utilities->api_status();
$headers = $client->utilities->headers();
```

### Universal Parameters

[](#universal-parameters)

All endpoints (other than utilities) supports universal parameters.

For instance, you can change the format to CSV

```
$option_chain = $client->options->option_chain(
    symbol: 'AAPL',
    expiration: '2028-12-15',
    side: Side::CALL,
    parameters: new Parameters(format: Format::CSV),
);

```

Testing
-------

[](#testing)

### Running Tests Locally

[](#running-tests-locally)

Run all tests with PHPUnit:

```
./vendor/bin/phpunit
```

### Testing Across PHP Versions

[](#testing-across-php-versions)

To test the SDK across all supported PHP versions (8.2, 8.3, 8.4, 8.5), use the provided script:

```
# Test all PHP versions (8.2, 8.3, 8.4, 8.5) with both prefer-lowest and prefer-stable
./test-with-act.sh

# Quick test: Test a specific PHP version only (prefer-stable)
./test-with-act.sh 8.5
./test-with-act.sh 8.4
./test-with-act.sh 8.3
./test-with-act.sh 8.2
```

**Note:** This script uses [act](https://github.com/nektos/act) to run the GitHub Actions workflow locally. It requires:

- Docker installed and running
- `act` installed (`brew install act` on macOS, or see [act installation guide](https://github.com/nektos/act#installation))

**Integration Tests:** Set the `MARKETDATA_TOKEN` environment variable before running to include integration tests:

```
export MARKETDATA_TOKEN=your_token_here
./test-with-act.sh
```

Contributing
------------

[](#contributing)

Found a bug or want to contribute? See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on:

- Reporting bugs with reproduction code
- Setting up a development environment
- Running tests
- Submitting pull requests

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [KerryJones](https://github.com/KerryJones)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance75

Regular maintenance activity

Popularity24

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 67.6% 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 ~45 days

Recently: every ~143 days

Total

14

Last Release

77d ago

Major Versions

v0.6.2-beta → v1.0.02026-02-20

PHP version history (2 changes)v0.1.0-alphaPHP ^8.1

v1.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab2a4276f552a3ef466da4a72c170612e4a666022a95c50b7518117a46c10db0?d=identicon)[KerryJones](/maintainers/KerryJones)

![](https://www.gravatar.com/avatar/95e65a27046ca9ef066133c2b6b179470c9b28354cbbb1987f6315c13f32a6e7?d=identicon)[MarketDataApp](/maintainers/MarketDataApp)

---

Top Contributors

[![MarketDataApp](https://avatars.githubusercontent.com/u/112879596?v=4)](https://github.com/MarketDataApp "MarketDataApp (194 commits)")[![KerryJones](https://avatars.githubusercontent.com/u/2685411?v=4)](https://github.com/KerryJones "KerryJones (90 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

apimarketdataoptions-apioptions-tradingphpstock-apistock-marketMarketDataAppmarketdataapp-sdk-php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/marketdataapp-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/marketdataapp-sdk-php/health.svg)](https://phpackages.com/packages/marketdataapp-sdk-php)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M648](/packages/sylius-sylius)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[atymic/twitter

Twitter API for PHP &amp; Laravel

945555.4k2](/packages/atymic-twitter)[netflie/whatsapp-cloud-api

The first PHP SDK to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform

640431.7k4](/packages/netflie-whatsapp-cloud-api)[ashallendesign/laravel-exchange-rates

A wrapper package for interacting with the exchangeratesapi.io API.

485677.8k](/packages/ashallendesign-laravel-exchange-rates)

PHPackages © 2026

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