Download the PHP package danielgnh/polymarket-php without Composer

On this page you can find all versions of the php package danielgnh/polymarket-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package polymarket-php

Polymarket PHP SDK

Polymarket API PHP SDK for interacting with the prediction markets and managing orders.

You can search for the markets, events, create / delete orders, send concurrent requests and much more.

What is polymarket?

Latest Version on Packagist PHP Version Total Downloads License Tests PHPStan

Requirements

Installation

Install the package via Composer:

Configuration

Add your polymarket credentials to your .env file:

Here is documentation how to export you private key

Quick Start

API Architecture

Polymarket uses three separate API systems:

The SDK provides separate client interfaces for each:

API Reference

Client Initialization

Configuration Options

The SDK supports the following configuration options:

Option Type Default Description
gamma_base_url string https://gamma-api.polymarket.com Gamma API base URL
clob_base_url string https://clob.polymarket.com CLOB API base URL
bridge_base_url string https://bridge-api.polymarket.com Bridge API base URL
timeout int 30 Request timeout in seconds
retries int 3 Number of retry attempts for failed requests
verify_ssl bool true Whether to verify SSL certificates

Markets (Gamma API)

The Markets resource provides access to prediction market data via the Gamma API.

List Markets

Parameters:

Returns: Array of market data

Get Market by ID

Parameters:

Returns: Market data array

Search Markets

Parameters:

Returns: Array of matching markets

Orders (CLOB API)

The Orders resource handles order management and execution via the CLOB API.

List Orders

Parameters:

Returns: Array of order data

Get Order by ID

Parameters:

Returns: Order data array

Create Order

Parameters:

Important: Always use strings for price and amount values to maintain decimal precision.

Returns: Created order data array

Cancel Order

Parameters:

Returns: Cancellation result data

Bridge (Cross-Chain Deposits)

The Bridge API enables you to fund your Polymarket account from multiple blockchains including Ethereum, Arbitrum, Base, Optimism, Solana, and Bitcoin. All deposits are automatically converted to USDC.e on Polygon.

Get Supported Assets

Retrieve information about supported chains, tokens, and minimum deposit amounts:

Returns: Array containing:

Generate Deposit Addresses

Generate unique deposit addresses for cross-chain funding:

Parameters:

Returns: Array of deposit addresses:

Important Security Notes:

Supported Blockchains

EVM-Compatible Chains:

Other Chains:

Deposit Workflow

  1. Call supportedAssets() to check supported tokens and minimum amounts
  2. Generate deposit addresses using generate() with your Polygon address
  3. Send assets to the provided address for your chosen blockchain
  4. Bridge service automatically detects and processes the deposit
  5. Assets are converted to USDC.e and sent to your Polygon address
  6. You can now trade on Polymarket

Processing Times:

Complete Example

For a complete working example, see examples/bridge-deposit.php.

Error Handling

The SDK provides a comprehensive exception hierarchy for handling different error scenarios:

Enums

The SDK provides type-safe enums for API fields with fixed value sets, ensuring compile-time safety and better IDE autocomplete.

Available Enums

OrderSide

Specifies whether you're buying or selling shares:

OrderType

Determines the execution behavior of an order:

OrderStatus

Indicates the current state of an order:

SignatureType

For order authentication methods:

Usage Example

Working with Decimal Values

When working with financial data (prices, amounts), always use string representation to maintain precision:

Concurrent Requests

For improved performance when fetching multiple resources, use the concurrent methods.

Batch Fetching

Fetch multiple items in parallel with automatic concurrency control:

Promise-Based API

For custom workflows, use the async methods that return promises:

Available Async Methods

Gamma Markets:

CLOB Markets:

CLOB Orders:

Configuration

Configure default concurrency and timeout:

Development

Running Tests

Code Style

Format code using PHP CS Fixer:

Check code style without making changes:

Static Analysis

Run PHPStan for static analysis:

Test Coverage

Generate test coverage report:

Coverage reports will be generated in the coverage/ directory.

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Follow PSR-12 coding standards
  2. Write tests for new features
  3. Run composer cs-fix before committing
  4. Ensure all tests pass with composer test
  5. Run static analysis with composer phpstan

Security

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

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

Resources

Support

For bugs and feature requests, please use the GitHub issue tracker.


All versions of polymarket-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-gmp Version *
guzzlehttp/guzzle Version ^7.0
guzzlehttp/promises Version ^2.0
kornrunner/ethereum-address Version ^0.4.0
kornrunner/ethereum-util Version ^0.2.0
kornrunner/keccak Version ^1.1
kornrunner/secp256k1 Version ^0.3.0
phpseclib/phpseclib Version ^3.0
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/log Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package danielgnh/polymarket-php contains the following files

Loading the files please wait ...