PHPackages                             polymarket-php/polymarket-laravel - 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. polymarket-php/polymarket-laravel

ActiveLibrary[API Development](/categories/api)

polymarket-php/polymarket-laravel
=================================

Laravel adapter for the Polymarket PHP - Integrate prediction markets into your Laravel applications

v0.1.4(2mo ago)339↓50%1MITPHPPHP ^8.2CI passing

Since Dec 12Pushed 2mo ago1 watchersCompare

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

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

Polymarket Laravel
==================

[](#polymarket-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4b5eaf609b64e8579d672cdc464e1196efe4356841ca24f3c6f08f99602cb9ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706f6c796d61726b65742d7068702f706f6c796d61726b65742d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/polymarket-php/polymarket-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/9ef6ed04ae41e4c2e215fb46e2fd86499c248919bf78c8e925e2c88f701c81fe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706f6c796d61726b65742d7068702f706f6c796d61726b65742d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/polymarket-php/polymarket-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/7b5a73e52193be6b1618dc14e286683bfdb4cb94e3055982d1f39400ac4b5f73/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706f6c796d61726b65742d7068702f706f6c796d61726b65742d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/polymarket-php/polymarket-laravel)

This is a Laravel adapter for the [Polymarket PHP SDK](https://github.com/polymarket-php/polymarket-php), providing easy ways to integrate polymarket in your Laravel application.

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 10.x, 11.x, or 12.x

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

[](#installation)

You can install the package via Composer:

```
composer require polymarket-php/polymarket-laravel
```

### Quick Setup

[](#quick-setup)

Run the install command for guided setup:

```
php artisan polymarket:install
```

This will:

- Publish the configuration file
- Display instructions for adding credentials to your `.env` file

### Manual Setup

[](#manual-setup)

Alternatively, you can publish the configuration file manually:

```
php artisan vendor:publish --tag="polymarket-config"
```

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

[](#configuration)

Add your Polymarket credentials to your `.env` file:

```
POLYMARKET_API_KEY=your-api-key
POLYMARKET_PRIVATE_KEY=0x...
POLYMARKET_CHAIN_ID=137
```

### Configuration Options

[](#configuration-options)

All configuration options can be customized in `config/polymarket.php`:

OptionEnvironment VariableDefaultDescription`api_key``POLYMARKET_API_KEY``null`API key for authenticated requests (optional for read-only)`private_key``POLYMARKET_PRIVATE_KEY``null`Private key for trading operations`chain_id``POLYMARKET_CHAIN_ID``137`Blockchain network (137 = Polygon mainnet)`gamma_base_url``POLYMARKET_GAMMA_BASE_URL``https://gamma-api.polymarket.com`Gamma API base URL`clob_base_url``POLYMARKET_CLOB_BASE_URL``https://clob.polymarket.com`CLOB API base URL`bridge_base_url``POLYMARKET_BRIDGE_BASE_URL``https://bridge-api.polymarket.com`Bridge API base URL`timeout``POLYMARKET_TIMEOUT``30`Request timeout in seconds`retries``POLYMARKET_RETRIES``3`Number of retry attempts`verify_ssl``POLYMARKET_VERIFY_SSL``true`Enable SSL certificate verificationUsage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

The facade provides convenient static access to the Polymarket client:

```
use PolymarketPhp\PolymarketLaravel\Facades\Polymarket;

// Fetch markets
$markets = Polymarket::gamma()->markets()->all();

// Search for specific markets
$markets = Polymarket::gamma()->markets()->search('election');

// Get a specific market
$market = Polymarket::gamma()->markets()->get('market-id');
```

### Dependency Injection

[](#dependency-injection)

Inject the client directly into your classes:

```
use PolymarketPhp\Polymarket\Client;

class MarketController extends Controller
{
    public function __construct(
        private Client $polymarket
    ) {}

    public function index()
    {
        $markets = $this->polymarket->gamma()->markets()->all();

        return view('markets.index', compact('markets'));
    }

    public function show(string $id)
    {
        $market = $this->polymarket->gamma()->markets()->get($id);

        return view('markets.show', compact('market'));
    }
}
```

Trading Operations (CLOB API)
-----------------------------

[](#trading-operations-clob-api)

For trading operations, you need to configure both an API key and private key:

```
use PolymarketPhp\PolymarketLaravel\Facades\Polymarket;

// Authenticate for trading
Polymarket::auth();

// Place an order
$order = Polymarket::clob()->orders()->create([
    'market' => 'market-id',
    'side' => 'BUY',
    'price' => 0.5,
    'size' => 100,
]);

// Get your orders
$orders = Polymarket::clob()->orders()->list();

// Cancel an order
Polymarket::clob()->orders()->cancel($orderId);
```

Bridge API (Cross-Chain Deposits)
---------------------------------

[](#bridge-api-cross-chain-deposits)

The Bridge API enables deposits from multiple chains, automatically converting to USDC.e on Polygon:

```
use PolymarketPhp\PolymarketLaravel\Facades\Polymarket;

// Access the Bridge API
$bridge = Polymarket::bridge();

// Supported chains: Ethereum, Arbitrum, Base, Optimism, Solana, Bitcoin
```

Market Data Examples
--------------------

[](#market-data-examples)

### Fetching All Markets

[](#fetching-all-markets)

```
use PolymarketPhp\PolymarketLaravel\Facades\Polymarket;

// Get all markets with pagination
$markets = Polymarket::gamma()->markets()->all([
    'limit' => 20,
    'offset' => 0,
]);

foreach ($markets as $market) {
    echo $market['question'] . PHP_EOL;
}
```

### Searching Markets

[](#searching-markets)

```
// Search for election-related markets
$results = Polymarket::gamma()->markets()->search('election', [
    'limit' => 10,
]);

// Search with filters
$results = Polymarket::gamma()->markets()->search('crypto', [
    'active' => true,
    'closed' => false,
]);
```

### Getting Market Details

[](#getting-market-details)

```
$marketId = 'some-market-id';
$market = Polymarket::gamma()->markets()->get($marketId);

echo "Question: {$market['question']}" . PHP_EOL;
echo "Volume: {$market['volume']}" . PHP_EOL;
echo "Liquidity: {$market['liquidity']}" . PHP_EOL;
```

Error Handling
--------------

[](#error-handling)

The SDK throws specific exceptions for different error scenarios:

```
use PolymarketPhp\Polymarket\Exceptions\AuthenticationException;
use PolymarketPhp\Polymarket\Exceptions\NotFoundException;
use PolymarketPhp\Polymarket\Exceptions\RateLimitException;
use PolymarketPhp\Polymarket\Exceptions\ValidationException;
use PolymarketPhp\PolymarketLaravel\Facades\Polymarket;

try {
    $market = Polymarket::gamma()->markets()->get($marketId);
} catch (NotFoundException $e) {
    // Market not found
    return response()->json(['error' => 'Market not found'], 404);
} catch (RateLimitException $e) {
    // Rate limit exceeded
    return response()->json(['error' => 'Too many requests'], 429);
} catch (AuthenticationException $e) {
    // Authentication failed
    return response()->json(['error' => 'Unauthorized'], 401);
} catch (ValidationException $e) {
    // Invalid request parameters
    return response()->json(['error' => $e->getMessage()], 422);
}
```

Testing
-------

[](#testing)

The package includes comprehensive tests:

```
# Run tests
composer test

# Run static analysis
composer analyse

# Fix code style
composer format
```

### Mocking in Your Tests

[](#mocking-in-your-tests)

You can easily mock the Polymarket client in your tests:

```
use PolymarketPhp\PolymarketLaravel\Facades\Polymarket;
use PolymarketPhp\Polymarket\Client;

public function test_it_fetches_markets()
{
    $mockClient = Mockery::mock(Client::class);
    $mockClient->shouldReceive('gamma->markets->all')
        ->once()
        ->andReturn(['market1', 'market2']);

    $this->app->instance(Client::class, $mockClient);

    // Your test code...
}
```

Advanced Configuration
----------------------

[](#advanced-configuration)

### Custom Timeouts

[](#custom-timeouts)

For long-running operations, adjust the timeout:

```
POLYMARKET_TIMEOUT=60
```

### Retry Configuration

[](#retry-configuration)

Configure automatic retry behavior:

```
POLYMARKET_RETRIES=5
```

### Local Development

[](#local-development)

Disable SSL verification for local testing (not recommended for production):

```
POLYMARKET_VERIFY_SSL=false
```

### Custom API URLs

[](#custom-api-urls)

Use custom API endpoints (useful for testing):

```
POLYMARKET_GAMMA_BASE_URL=https://custom-gamma-api.example.com
POLYMARKET_CLOB_BASE_URL=https://custom-clob-api.example.com
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on recent changes.

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

[](#contributing)

Contributions are welcome! In case if you found any bug or have an idea just open an issue and create a Pull Request.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Daniel Goncharov](https://github.com/danielgnh)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

40

—

FairBetter than 87% of packages

Maintenance88

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96% 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 ~15 days

Total

5

Last Release

88d ago

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

v0.1.4PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7fc66414f26e8bed17a1a0f212b2f24776c2a0ba5044b501163300f14f4b04a1?d=identicon)[danielgnh](/maintainers/danielgnh)

---

Top Contributors

[![danielgnh](https://avatars.githubusercontent.com/u/33636385?v=4)](https://github.com/danielgnh "danielgnh (24 commits)")[![hms5232](https://avatars.githubusercontent.com/u/43672033?v=4)](https://github.com/hms5232 "hms5232 (1 commits)")

---

Tags

laravellaravel-packagepolymarketpolymarket-apiprediction-marketslaravelpolymarketpolymarket laravelpolymarket apilaravel trading agentpolymarket framework

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/polymarket-php-polymarket-laravel/health.svg)

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

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.0k7.8M55](/packages/dedoc-scramble)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)[likeabas/filament-chatgpt-agent

Integrate with OpenAI ChatGPT

235.3k](/packages/likeabas-filament-chatgpt-agent)

PHPackages © 2026

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