1. Go to this page and download the library: Download danielgnh/polymarket-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
danielgnh / polymarket-php example snippets
use PolymarketPhp\Polymarket\Client;
/*
* Let's initialize the client.
* In case if you defined the POLYMARKET_API_KEY you don't need to pass any parameters in Client
*/
$client = new Client();
/*
* In case if you want to define any other API Key, you can do it as well.
*/
$client = new Client('api-key');
use PolymarketPhp\Polymarket\Client;
/* There is a way to initialize the client with custom configuration */
$client = new Client('your-api-key', [
'gamma_base_url' => 'https://gamma-api.polymarket.com',
'clob_base_url' => 'https://clob.polymarket.com',
'bridge_base_url' => 'https://bridge-api.polymarket.com',
'timeout' => 30,
'retries' => 3,
'verify_ssl' => true,
]);
use PolymarketPhp\Polymarket\Enums\OrderSide;
OrderSide::BUY // Buy shares
OrderSide::SELL // Sell shares
use PolymarketPhp\Polymarket\Enums\OrderType;
OrderType::FOK // Fill-Or-Kill: Execute immediately in full or cancel
OrderType::FAK // Fill-And-Kill: Execute immediately for available shares, cancel remainder
OrderType::GTC // Good-Til-Cancelled: Active until fulfilled or cancelled
OrderType::GTD // Good-Til-Date: Active until specified date
use PolymarketPhp\Polymarket\Enums\OrderStatus;
OrderStatus::MATCHED // Matched with existing order
OrderStatus::LIVE // Resting on the order book
OrderStatus::DELAYED // Marketable but subject to matching delay
OrderStatus::UNMATCHED // Marketable but experiencing delay