1. Go to this page and download the library: Download coinpaprika/dexpaprika-sdk 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/ */
coinpaprika / dexpaprika-sdk example snippets
// Before
$pools = $client->dexes->getDexPools('ethereum', 'uniswap_v3', ['limit' => 15]);
foreach ($pools['pools'] as $pool) {
echo $pool['volume_usd'];
}
// After
$pools = $client->dexes->getDexPools('ethereum', 'uniswap_v3', ['limit' => 15]);
foreach ($pools['results'] as $pool) {
echo $pool['id'] . ' ' . $pool['volume_usd_24h'];
}
// Page with the cursor. Paging past the first page needs an API key (a free
// key pages without limit), configured before the client that uses it:
// https://console.dexpaprika.com
$config = (new Config())->setApiKey(getenv('DEXPAPRIKA_API_KEY'));
$client = new Client(null, null, false, $config);
$next = $client->dexes->getDexPools('ethereum', 'uniswap_v3', [
'limit' => 15,
'cursor' => $pools['next_cursor'],
]);
// OLD - No longer works
$pools = $client->pools->getTopPools(['limit' => 10]);
// NEW - Network-specific approach
$ethereumPools = $client->pools->getNetworkPools('ethereum', ['limit' => 10]);
$solanaPools = $client->pools->getNetworkPools('solana', ['limit' => 10]);
$page = $client->pools->getNetworkPools('ethereum', ['limit' => 20]);
$page['results']; // array of items
$page['has_next_page']; // bool
$page['next_cursor']; // string|null
// Fetch the next page with the cursor. Paging past the first page needs an
// API key (a free key pages without limit), configured before the client
// that uses it: https://console.dexpaprika.com
$config = (new Config())->setApiKey(getenv('DEXPAPRIKA_API_KEY'));
$client = new Client(null, null, false, $config);
$next = $client->pools->getNetworkPools('ethereum', [
'limit' => 20,
'cursor' => $page['next_cursor'],
]);
DexPaprika\Client;
use DexPaprika\Exception\DexPaprikaApiException;
try {
// Create client
$client = new Client();
// Get list of supported networks
$networks = $client->networks->getNetworks();
// Get global statistics
$stats = $client->utils->getStats();
// Get top pools by network (NEW in v1.3.0)
$ethereumPools = $client->pools->getNetworkPools('ethereum', ['limit' => 10]);
$solanaPools = $client->pools->getNetworkPools('solana', ['limit' => 10]);
// Search for tokens
$searchResults = $client->search->search('bitcoin');
// Get token details
$token = $client->tokens->getTokenDetails('ethereum', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2');
} catch (DexPaprikaApiException $e) {
echo "API Error: " . $e->getMessage();
}
use DexPaprika\Client;
use DexPaprika\Config;
// Explicit
$config = (new Config())->setApiKey('api_your_key_here');
$client = new Client(null, null, false, $config);
// Or leave it out and set DEXPAPRIKA_API_KEY in the environment
$client = new Client();
$config = (new Config())
->setApiKey('api_your_pro_key')
->setBaseUrl('https://api-pro.dexpaprika.com');
use DexPaprika\Client;
use DexPaprika\Config;
// Create configuration
$config = new Config();
$config->setResponseFormat('object') // Get responses as objects instead of arrays
->setTimeout(30) // Set request timeout in seconds
->setUserAgent('MyApp/1.0') // Set custom user agent
->setMaxRetries(3) // Set maximum retry attempts
->setRetryDelays([100, 500, 1000]); // Set retry delays in milliseconds
// Create client with configuration
$client = new Client($config);
use DexPaprika\Client;
use DexPaprika\Cache\FilesystemCache;
// Enable caching with default settings (filesystem cache, 1 hour TTL)
$client = new Client();
$client->setupCache();
// Custom cache TTL (5 minutes)
$client->setupCache(null, 300);
// Custom cache directory
$customCache = new FilesystemCache('/path/to/cache');
$client->setupCache($customCache);
// Disable caching
$client->getConfig()->setCacheEnabled(false);
// Enable caching
$client->getConfig()->setCacheEnabled(true);
// Create a client with caching enabled from the beginning
$config = new Config();
$cache = new FilesystemCache();
$config->setCache($cache)->setCacheEnabled(true);
$client = new Client(null, null, false, $config);
use DexPaprika\Client;
use DexPaprika\Config;
// Configure retry behavior
$config = new Config();
$config->setMaxRetries(5); // Maximum number of retry attempts
$config->setRetryDelays([100, 500, 1000, 2500, 5000]); // Delay in milliseconds for each attempt
$client = new Client(null, null, false, $config);
$config = new Config();
$sleeps = [];
$config->setSleeper(function (int $milliseconds) use (&$sleeps) {
$sleeps[] = $milliseconds; // record instead of actually waiting
});
// Get all supported networks
$networks = $client->networks->getNetworks();
// Get global DEX statistics
$stats = $client->utils->getStats();
// Get all DEXes on a specific network
$dexes = $client->dexes->getNetworkDexes('ethereum', ['limit' => 10]);
// Get pools on a specific network (UPDATED in v1.3.0)
$ethPools = $client->pools->getNetworkPools('ethereum', ['limit' => 20]);
$solanaPools = $client->pools->getNetworkPools('solana', ['limit' => 20]);
// Get pools on a specific DEX (cursor-paginated, rows under 'results')
$uniswapPools = $client->dexes->getDexPools('ethereum', 'uniswap_v3', ['limit' => 15]);
$uniswapPools['results'][0]['volume_usd_24h'];
// Get detailed information about a pool
$poolDetails = $client->pools->getPoolDetails('ethereum', '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640');
// Hourly OHLCV candles for the last 24 hours, which works without a key
$ohlcvData = $client->pools->getPoolOHLCV('ethereum', '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640',
'-24h', [
'interval' => '1h',
'limit' => 24
]
);
// Get transactions for a pool
$transactions = $client->pools->getPoolTransactions('ethereum', '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640', ['limit' => 20]);
// Only the last hour of transactions
$lastHour = $client->pools->getPoolTransactions('ethereum', '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640', ['limit' => 20, 'from' => '-1h']);
// Get detailed information about a token
$tokenDetails = $client->tokens->getTokenDetails('ethereum', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2');
// Find token by name or address
$token = $client->tokens->findToken('ethereum', 'WETH');
// Get pools containing a specific token (UPDATED in v1.5.0).
// Backed by /networks/{network}/pools/search with token_address: the filter is
// network-scoped, rows come back under 'results', and pagination is
// cursor-based ('cursor' option / 'next_cursor' in the response).
$tokenPools = $client->tokens->getTokenPools('ethereum', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', [
'limit' => 20,
]);
foreach ($tokenPools['results'] as $pool) {
echo $pool['id'] . ': ' . $pool['volume_usd_24h'] . "\n";
}
// The removed endpoint's 'address' (pair filter) and 'reorder' options have no
// /pools/search equivalent and are ignored. To match a pair, filter client-side:
$usdc = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';
$pairPools = array_filter($tokenPools['results'], function ($pool) use ($usdc) {
return in_array($usdc, array_column($pool['tokens'] ?? [], 'id'), true);
});
// Pools that fell 10% or more in the last hour, worst first
$dumping = $client->pools->filterPools('ethereum', [
'priceChangePercentage1hMax' => -10,
'liquidityUsdMin' => 10000,
'sortBy' => 'price_change_percentage_1h',
'sortDir' => 'asc',
'limit' => 10,
]);
// Fastest movers over the last five minutes
$movers = $client->pools->getNetworkPools('ethereum', [
'orderBy' => 'price_change_percentage_5m',
'sort' => 'desc',
'limit' => 10,
]);
// Pools up 100% or more over two days
$doubled = $client->pools->filterPools('ethereum', [
'priceChangePercentage48hMin' => 100,
'sortBy' => 'price_change_percentage_48h',
'sortDir' => 'desc',
'limit' => 10,
]);
// Tokens down 20% or more on the day
$dropped = $client->tokens->filterTokens('ethereum', [
'priceChangePercentage24hMax' => -20,
'limit' => 10,
]);
// Get top tokens by volume
$topTokens = $client->tokens->getTopTokens('ethereum', [
'orderBy' => 'volume_24h',
'limit' => 10,
]);
// Filter tokens by criteria
$filtered = $client->tokens->filterTokens('ethereum', [
'volume24hMin' => 100000,
'fdvMin' => 1000000,
'limit' => 10,
]);
// Get prices for multiple tokens in one request (max 10)
$prices = $client->tokens->getMultiPrices('ethereum', [
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', // WETH
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC
]);
foreach ($prices as $p) {
echo "{$p['id']}: \${$p['price_usd']}\n";
}
// Search for tokens, pools, and DEXes
$searchResults = $client->search->search('bitcoin');
// When initializing the client
$config = new Config();
$config->setResponseFormat('object');
$client = new Client($config);
// After initialization
$client->getConfig()->setResponseFormat('object');
// Get results as objects
$networks = $client->networks->getNetworks();
echo $networks[0]->display_name;
use DexPaprika\Exception\DexPaprikaApiException;
use DexPaprika\Exception\NotFoundException;
use DexPaprika\Exception\DeprecationException;
use DexPaprika\Exception\ValidationException;
use DexPaprika\Exception\RateLimitException;
use DexPaprika\Exception\ServerException;
use DexPaprika\Exception\NetworkException;
try {
// This will throw DeprecationException in v1.3.0+
$pools = $client->pools->getTopPools();
} catch (DeprecationException $e) {
// Handle deprecated endpoint usage
echo "Deprecated endpoint: " . $e->getMessage();
// Get migration guidance from error data
$errorData = $e->getErrorData();
if (isset($errorData['migration_examples'])) {
echo "Migration examples:\n";
foreach ($errorData['migration_examples'] as $example) {
echo " {$example}\n";
}
}
} catch (ValidationException $e) {
// Handle parameter validation errors
echo "Invalid parameters: " . $e->getMessage();
} catch (NotFoundException $e) {
// Handle not found error
echo "Resource not found: " . $e->getMessage();
} catch (RateLimitException $e) {
// Handle rate limiting
echo "Rate limit exceeded. Try again later.";
} catch (ServerException $e) {
// Handle server errors
echo "Server error: " . $e->getMessage();
} catch (NetworkException $e) {
// Handle network connectivity issues
echo "Network error: " . $e->getMessage();
} catch (DexPaprikaApiException $e) {
// Handle API errors
echo "API Error: " . $e->getMessage() . " (Code: " . $e->getCode() . ")";
// Get raw error response
$errorData = $e->getErrorData();
} catch (Exception $e) {
// Handle general errors
echo "Error: " . $e->getMessage();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.