PHPackages                             tigusigalpa/marketstack-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. tigusigalpa/marketstack-php

ActiveLibrary[API Development](/categories/api)

tigusigalpa/marketstack-php
===========================

A modern PHP/Laravel package for interacting with the Marketstack API

v1.0.0(3mo ago)60MITPHPPHP ^8.1

Since Jan 31Pushed 2mo agoCompare

[ Source](https://github.com/tigusigalpa/marketstack-php)[ Packagist](https://packagist.org/packages/tigusigalpa/marketstack-php)[ RSS](/packages/tigusigalpa-marketstack-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Marketstack PHP - API Client for Laravel
========================================

[](#marketstack-php---api-client-for-laravel)

[![Marketstack PHP SDK](https://private-user-images.githubusercontent.com/2721390/543219238-1b1d4c17-550f-4fd9-8c97-024cb63f204c.jpg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU0Mzc1NzgsIm5iZiI6MTc3NTQzNzI3OCwicGF0aCI6Ii8yNzIxMzkwLzU0MzIxOTIzOC0xYjFkNGMxNy01NTBmLTRmZDktOGM5Ny0wMjRjYjYzZjIwNGMuanBnP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDZUMDEwMTE4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OWQyYzAwMzJlMjQwMjYyZWZkNDdiOGZmOGQyZGZjN2FiOGY3NTg2ODgxZDc3MDNhZDgyYWE3YzNhOTgxYmJlOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.vPjXmlbbZ4Pe_Fsc9JWo6V-cV8jQzE9ZLxaHabzaMHY)](https://private-user-images.githubusercontent.com/2721390/543219238-1b1d4c17-550f-4fd9-8c97-024cb63f204c.jpg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU0Mzc1NzgsIm5iZiI6MTc3NTQzNzI3OCwicGF0aCI6Ii8yNzIxMzkwLzU0MzIxOTIzOC0xYjFkNGMxNy01NTBmLTRmZDktOGM5Ny0wMjRjYjYzZjIwNGMuanBnP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDZUMDEwMTE4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OWQyYzAwMzJlMjQwMjYyZWZkNDdiOGZmOGQyZGZjN2FiOGY3NTg2ODgxZDc3MDNhZDgyYWE3YzNhOTgxYmJlOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.vPjXmlbbZ4Pe_Fsc9JWo6V-cV8jQzE9ZLxaHabzaMHY)

[![Latest Version on Packagist](https://camo.githubusercontent.com/45f076b265400d8d7d7639fb82988d1efbc47a5e8bf43e979a9961150e645ef7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74696775736967616c70612f6d61726b6574737461636b2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tigusigalpa/marketstack-php)[![PHP Version](https://camo.githubusercontent.com/a0f03065a92c8b764dd013d02d1952fe946aa60d9d9e6834060fd2df77049a1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f74696775736967616c70612f6d61726b6574737461636b2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tigusigalpa/marketstack-php)[![License](https://camo.githubusercontent.com/885a6fc2e5b344d6ac6f1423669fd36248b76d7aa2e6d11daf4dd1191dc682ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74696775736967616c70612f6d61726b6574737461636b2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tigusigalpa/marketstack-php)

**Marketstack PHP** is a PHP client for the [Marketstack REST API](https://docs.apilayer.com/marketstack/docs/api-documentation), built with first-class support for the Laravel framework. It provides a convenient and flexible interface for integrating stock market data into your applications, whether you need real-time quotes, historical prices, or intraday data.

The package is designed for PHP 8.1+ and Laravel 10/11, providing a modern and developer-friendly toolkit.

What is Marketstack?
--------------------

[](#what-is-marketstack)

[Marketstack](https://marketstack.com/) is a service that provides a REST API for accessing stock market data. It covers over 125,000 stock tickers from 72 global exchanges, including NYSE, NASDAQ, LSE, and more. This SDK simplifies the integration of Marketstack's financial data into your Laravel projects, such as trading platforms, portfolio trackers, and financial analytics tools.

Key Features
------------

[](#key-features)

- **Fluent Interface:** An elegant, chainable syntax for writing clean and expressive code.
- **Native Laravel Integration:** The package includes a service provider, facade, and configuration file, allowing you to get started with minimal setup.
- **Type-Safe DTOs:** The use of Data Transfer Objects (DTOs) provides IDE autocompletion and improves code reliability.
- **Fully Tested:** All package functionality is thoroughly tested using Pest.
- **PSR-12 Compliant:** The code adheres to modern PHP standards.
- **Multiple Response Formats:** Get data as Laravel Collections, DTOs, JSON, or a raw HTTP response.
- **Error Handling:** Custom exceptions for convenient debugging.

Quick Start
-----------

[](#quick-start)

Getting stock market data takes just a few lines of code:

```
use Tigusigalpa\Marketstack\Facades\Marketstack;

// Get the latest stock price for Apple
$stock = Marketstack::eod()->latest(\'AAPL\')->dto();
echo "AAPL closed at: $" . $stock->close;

```

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

[](#installation)

You can install the package via Composer:

```
composer require tigusigalpa/marketstack-php
```

### Publish Configuration

[](#publish-configuration)

Publish the configuration file to customize its settings:

```
php artisan vendor:publish --tag=marketstack-config
```

This will create a `config/marketstack.php` file in your application.

### Environment Configuration

[](#environment-configuration)

Add your Marketstack API key to your `.env` file:

```
MARKETSTACK_API_KEY=your_api_key_here
MARKETSTACK_USE_HTTPS=false  # Set to true for paid plans
MARKETSTACK_TIMEOUT=30
```

> **Note**: HTTPS is only available for paid Marketstack plans. Free plans must use HTTP.

Usage
-----

[](#usage)

The package provides a convenient interface for all Marketstack API endpoints.

### End-of-Day (EOD) Data

[](#end-of-day-eod-data)

```
// Get EOD data with a date range
$eodData = Marketstack::eod()
    ->symbols(\'AAPL\')
    ->dateFrom(\'2023-01-01\')
    ->dateTo(\'2023-12-31\')
    ->exchange(\'XNAS\')
    ->limit(100)
    ->collect();

// Get the latest EOD data for a ticker
$latest = Marketstack::eod()
    ->latest(\'AAPL\')
    ->dto();

```

### Intraday Data

[](#intraday-data)

```
// Get intraday data with an interval
$intraday = Marketstack::intraday()
    ->symbols(\'TSLA\')
    ->interval(\'1h\')  // Options: 1min, 5min, 10min, 15min, 30min, 1hour
    ->dateFrom(\'2023-01-15\')
    ->collect();

```

### Tickers

[](#tickers)

```
// Search for tickers
$searchResults = Marketstack::tickers()
    ->search(\'Apple\')
    ->collect();

// Get information for a specific ticker
$ticker = Marketstack::tickers()
    ->ticker(\'AAPL\')
    ->dto();

```

### Response Formats

[](#response-formats)

The package supports multiple response formats:

```
// Collection of DTOs (recommended)
$collection = Marketstack::eod()->symbols(\'AAPL\')->collect();

// Single DTO or null
$dto = Marketstack::eod()->latest(\'AAPL\')->dto();

// Raw JSON
$json = Marketstack::eod()->symbols(\'AAPL\')->json();

// Raw HTTP Response
$response = Marketstack::eod()->symbols(\'AAPL\')->get();

```

### Error Handling

[](#error-handling)

The package throws a `MarketstackException` when an API request fails:

```
use Tigusigalpa\Marketstack\Exceptions\MarketstackException;

try {
    $data = Marketstack::eod()->symbols(\'INVALID\')->collect();
} catch (MarketstackException $e) {
    echo "Error: {$e->getMessage()}";
}

```

Testing
-------

[](#testing)

Run the tests:

```
composer test
```

Run tests with a coverage report:

```
composer test -- --coverage
```

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

[](#requirements)

- **PHP**: 8.1+
- **Laravel**: 10.x or 11.x
- **Marketstack API Key**: [Free or paid plan](https://marketstack.com/)

Frequently Asked Questions
--------------------------

[](#frequently-asked-questions)

### Can I use this package without Laravel?

[](#can-i-use-this-package-without-laravel)

Yes! While optimized for Laravel, you can use the `MarketstackClient` class directly in any PHP 8.1+ project:

```
$client = new \Tigusigalpa\Marketstack\MarketstackClient(\'your-api-key\');
$data = $client->eod()->symbols(\'AAPL\')->collect();

```

### How do I handle API rate limits?

[](#how-do-i-handle-api-rate-limits)

The package throws a `MarketstackException` when rate limits are exceeded. You can implement retry logic or caching:

```
use Illuminate\Support\Facades\Cache;

try {
    $data = Marketstack::eod()->symbols(\'AAPL\')->collect();
    Cache::put(\'aapl_price\', $data, now()->addMinutes(15));
} catch (MarketstackException $e) {
    $data = Cache::get(\'aapl_price\'); // Use cached data
}

```

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](LICENSE).

Support &amp; Community
-----------------------

[](#support--community)

- **GitHub Issues**: [Report a bug or request a feature](https://github.com/tigusigalpa/marketstack-php/issues)
- **GitHub Discussions**: [Ask a question or share an idea](https://github.com/tigusigalpa/marketstack-php/discussions)

If you discover a security vulnerability, please send an email to .

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance83

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

100d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/76c3a1d93c3213a8a22b4b637708d8b66a1ba3a5252624046cae7683a198b3a8?d=identicon)[tigusigalpa](/maintainers/tigusigalpa)

---

Top Contributors

[![tigusigalpa](https://avatars.githubusercontent.com/u/2721390?v=4)](https://github.com/tigusigalpa "tigusigalpa (4 commits)")

---

Tags

apifinancefinancial-datalaravelmarketstackmarketstack-apiphprest-api

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/tigusigalpa-marketstack-php/health.svg)

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

###  Alternatives

[spatie/laravel-query-builder

Easily build Eloquent queries from API requests

4.4k26.9M220](/packages/spatie-laravel-query-builder)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

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