{"id":35096509,"url":"https://github.com/danielgnh/polymarket-laravel","last_synced_at":"2025-12-27T15:31:23.316Z","repository":{"id":328318529,"uuid":"1115083088","full_name":"danielgnh/polymarket-laravel","owner":"danielgnh","description":"Laravel adapter for the Polymarket PHP","archived":false,"fork":false,"pushed_at":"2025-12-12T15:31:39.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-13T22:55:07.423Z","etag":null,"topics":["laravel","laravel-package","polymarket","polymarket-api","prediction-markets"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielgnh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-12T10:10:35.000Z","updated_at":"2025-12-12T15:30:25.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/danielgnh/polymarket-laravel","commit_stats":null,"previous_names":["danielgnh/polymarket-laravel"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/danielgnh/polymarket-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgnh%2Fpolymarket-laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgnh%2Fpolymarket-laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgnh%2Fpolymarket-laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgnh%2Fpolymarket-laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielgnh","download_url":"https://codeload.github.com/danielgnh/polymarket-laravel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgnh%2Fpolymarket-laravel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28080485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-27T02:00:05.897Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","laravel-package","polymarket","polymarket-api","prediction-markets"],"created_at":"2025-12-27T15:31:22.610Z","updated_at":"2025-12-27T15:31:23.302Z","avatar_url":"https://github.com/danielgnh.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polymarket Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/danielgnh/polymarket-laravel.svg?style=flat-square)](https://packagist.org/packages/danielgnh/polymarket-laravel)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/danielgnh/polymarket-laravel/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/danielgnh/polymarket-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/danielgnh/polymarket-laravel.svg?style=flat-square)](https://packagist.org/packages/danielgnh/polymarket-laravel)\n\nThis is a Laravel adapter for the [Polymarket PHP SDK](https://github.com/danielgnh/polymarket-php), providing easy ways to integrate polymarket in your Laravel application.\n\n## Requirements\n\n- PHP 8.1 or higher\n- Laravel 10.x or 11.x\n\n## Installation\n\nYou can install the package via Composer:\n\n```bash\ncomposer require danielgnh/polymarket-laravel\n```\n\n### Quick Setup\n\nRun the install command for guided setup:\n\n```bash\nphp artisan polymarket:install\n```\n\nThis will:\n- Publish the configuration file\n- Display instructions for adding credentials to your `.env` file\n\n### Manual Setup\n\nAlternatively, you can publish the configuration file manually:\n\n```bash\nphp artisan vendor:publish --tag=\"polymarket-config\"\n```\n\n## Configuration\n\nAdd your Polymarket credentials to your `.env` file:\n\n```env\nPOLYMARKET_API_KEY=your-api-key\nPOLYMARKET_PRIVATE_KEY=0x...\nPOLYMARKET_CHAIN_ID=137\n```\n\n### Configuration Options\n\nAll configuration options can be customized in `config/polymarket.php`:\n\n| Option | Environment Variable | Default | Description |\n|--------|---------------------|---------|-------------|\n| `api_key` | `POLYMARKET_API_KEY` | `null` | API key for authenticated requests (optional for read-only) |\n| `private_key` | `POLYMARKET_PRIVATE_KEY` | `null` | Private key for trading operations |\n| `chain_id` | `POLYMARKET_CHAIN_ID` | `137` | Blockchain network (137 = Polygon mainnet) |\n| `gamma_base_url` | `POLYMARKET_GAMMA_BASE_URL` | `https://gamma-api.polymarket.com` | Gamma API base URL |\n| `clob_base_url` | `POLYMARKET_CLOB_BASE_URL` | `https://clob.polymarket.com` | CLOB API base URL |\n| `timeout` | `POLYMARKET_TIMEOUT` | `30` | Request timeout in seconds |\n| `retries` | `POLYMARKET_RETRIES` | `3` | Number of retry attempts |\n| `verify_ssl` | `POLYMARKET_VERIFY_SSL` | `true` | Enable SSL certificate verification |\n\n## Usage\n\n### Using the Facade\n\nThe facade provides convenient static access to the Polymarket client:\n\n```php\nuse Danielgnh\\PolymarketLaravel\\Facades\\Polymarket;\n\n// Fetch markets\n$markets = Polymarket::gamma()-\u003emarkets()-\u003eall();\n\n// Search for specific markets\n$markets = Polymarket::gamma()-\u003emarkets()-\u003esearch('election');\n\n// Get a specific market\n$market = Polymarket::gamma()-\u003emarkets()-\u003eget('market-id');\n```\n\n### Dependency Injection\n\nInject the client directly into your classes:\n\n```php\nuse Danielgnh\\PolymarketPhp\\Client;\n\nclass MarketController extends Controller\n{\n    public function __construct(\n        private Client $polymarket\n    ) {}\n\n    public function index()\n    {\n        $markets = $this-\u003epolymarket-\u003egamma()-\u003emarkets()-\u003eall();\n\n        return view('markets.index', compact('markets'));\n    }\n\n    public function show(string $id)\n    {\n        $market = $this-\u003epolymarket-\u003egamma()-\u003emarkets()-\u003eget($id);\n\n        return view('markets.show', compact('market'));\n    }\n}\n```\n\n## Trading Operations (CLOB API)\n\nFor trading operations, you need to configure both an API key and private key:\n\n```php\nuse Danielgnh\\PolymarketLaravel\\Facades\\Polymarket;\n\n// Authenticate for trading\nPolymarket::auth();\n\n// Place an order\n$order = Polymarket::clob()-\u003eorders()-\u003ecreate([\n    'market' =\u003e 'market-id',\n    'side' =\u003e 'BUY',\n    'price' =\u003e 0.5,\n    'size' =\u003e 100,\n]);\n\n// Get your orders\n$orders = Polymarket::clob()-\u003eorders()-\u003elist();\n\n// Cancel an order\nPolymarket::clob()-\u003eorders()-\u003ecancel($orderId);\n```\n\n## Market Data Examples\n\n### Fetching All Markets\n\n```php\nuse Danielgnh\\PolymarketLaravel\\Facades\\Polymarket;\n\n// Get all markets with pagination\n$markets = Polymarket::gamma()-\u003emarkets()-\u003eall([\n    'limit' =\u003e 20,\n    'offset' =\u003e 0,\n]);\n\nforeach ($markets as $market) {\n    echo $market['question'] . PHP_EOL;\n}\n```\n\n### Searching Markets\n\n```php\n// Search for election-related markets\n$results = Polymarket::gamma()-\u003emarkets()-\u003esearch('election', [\n    'limit' =\u003e 10,\n]);\n\n// Search with filters\n$results = Polymarket::gamma()-\u003emarkets()-\u003esearch('crypto', [\n    'active' =\u003e true,\n    'closed' =\u003e false,\n]);\n```\n\n### Getting Market Details\n\n```php\n$marketId = 'some-market-id';\n$market = Polymarket::gamma()-\u003emarkets()-\u003eget($marketId);\n\necho \"Question: {$market['question']}\" . PHP_EOL;\necho \"Volume: {$market['volume']}\" . PHP_EOL;\necho \"Liquidity: {$market['liquidity']}\" . PHP_EOL;\n```\n\n## Error Handling\n\nThe SDK throws specific exceptions for different error scenarios:\n\n```php\nuse Danielgnh\\PolymarketPhp\\Exceptions\\AuthenticationException;\nuse Danielgnh\\PolymarketPhp\\Exceptions\\NotFoundException;\nuse Danielgnh\\PolymarketPhp\\Exceptions\\RateLimitException;\nuse Danielgnh\\PolymarketPhp\\Exceptions\\ValidationException;\nuse Danielgnh\\PolymarketLaravel\\Facades\\Polymarket;\n\ntry {\n    $market = Polymarket::gamma()-\u003emarkets()-\u003eget($marketId);\n} catch (NotFoundException $e) {\n    // Market not found\n    return response()-\u003ejson(['error' =\u003e 'Market not found'], 404);\n} catch (RateLimitException $e) {\n    // Rate limit exceeded\n    return response()-\u003ejson(['error' =\u003e 'Too many requests'], 429);\n} catch (AuthenticationException $e) {\n    // Authentication failed\n    return response()-\u003ejson(['error' =\u003e 'Unauthorized'], 401);\n} catch (ValidationException $e) {\n    // Invalid request parameters\n    return response()-\u003ejson(['error' =\u003e $e-\u003egetMessage()], 422);\n}\n```\n\n## Testing\n\nThe package includes comprehensive tests:\n\n```bash\n# Run tests\ncomposer test\n\n# Run static analysis\ncomposer analyse\n\n# Fix code style\ncomposer format\n```\n\n### Mocking in Your Tests\n\nYou can easily mock the Polymarket client in your tests:\n\n```php\nuse Danielgnh\\PolymarketPhp\\Client;\nuse Danielgnh\\PolymarketLaravel\\Facades\\Polymarket;\n\npublic function test_it_fetches_markets()\n{\n    $mockClient = Mockery::mock(Client::class);\n    $mockClient-\u003eshouldReceive('gamma-\u003emarkets-\u003eall')\n        -\u003eonce()\n        -\u003eandReturn(['market1', 'market2']);\n\n    $this-\u003eapp-\u003einstance(Client::class, $mockClient);\n\n    // Your test code...\n}\n```\n\n## Advanced Configuration\n\n### Custom Timeouts\n\nFor long-running operations, adjust the timeout:\n\n```env\nPOLYMARKET_TIMEOUT=60\n```\n\n### Retry Configuration\n\nConfigure automatic retry behavior:\n\n```env\nPOLYMARKET_RETRIES=5\n```\n\n### Local Development\n\nDisable SSL verification for local testing (not recommended for production):\n\n```env\nPOLYMARKET_VERIFY_SSL=false\n```\n\n### Custom API URLs\n\nUse custom API endpoints (useful for testing):\n\n```env\nPOLYMARKET_GAMMA_BASE_URL=https://custom-gamma-api.example.com\nPOLYMARKET_CLOB_BASE_URL=https://custom-clob-api.example.com\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on recent changes.\n\n## Contributing\n\nContributions are welcome! In case if you found any bug or have an idea just open an issue and create a Pull Request.\n\n## Security\n\nIf you discover any security-related issues, please email security@example.com instead of using the issue tracker.\n\n## Credits\n\n- [Daniel Goncharov](https://github.com/danielgnh)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgnh%2Fpolymarket-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielgnh%2Fpolymarket-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgnh%2Fpolymarket-laravel/lists"}