CCXT cryptocurrency exchange library for PHP developers. Covers both REST API (standard) and WebSocket API (real-time). Helps install CCXT, connect to exchanges, fetch market data, place orders, stream live tickers/orderbooks, handle authentication, and manage errors in PHP 8.1+. Use when working with crypto exchanges in PHP projects, trading bots, or web applications. Supports both sync and async (ReactPHP) usage.
View on GitHubFebruary 5, 2026
Select agents to install to:
npx add-skill https://github.com/ccxt/ccxt/blob/0c7a01553eb8e9150ee5ac39bd64b3e9f0713955/.claude/skills/ccxt-php/SKILL.md -a claude-code --skill ccxt-phpInstallation paths:
.claude/skills/ccxt-php/# CCXT for PHP
A comprehensive guide to using CCXT in PHP projects for cryptocurrency exchange integration.
## Installation
### Via Composer (REST and WebSocket)
```bash
composer require ccxt/ccxt
```
### Required PHP Extensions
- cURL
- mbstring (UTF-8)
- PCRE
- iconv
- gmp (for some exchanges)
### Optional for Async/WebSocket
- ReactPHP (installed automatically with ccxt)
## Quick Start
### REST API - Synchronous
```php
<?php
date_default_timezone_set('UTC'); // Required!
require_once 'vendor/autoload.php';
$exchange = new \ccxt\binance();
$exchange->load_markets();
$ticker = $exchange->fetch_ticker('BTC/USDT');
print_r($ticker);
```
### REST API - Asynchronous (ReactPHP)
```php
<?php
use function React\Async\await;
date_default_timezone_set('UTC');
require_once 'vendor/autoload.php';
$exchange = new \ccxt\async\binance();
$ticker = await($exchange->fetch_ticker('BTC/USDT'));
print_r($ticker);
```
### WebSocket API - Real-time Updates
```php
<?php
use function React\Async\await;
use function React\Async\async;
date_default_timezone_set('UTC');
require_once 'vendor/autoload.php';
$exchange = new \ccxt\pro\binance();
while (true) {
$ticker = await($exchange->watch_ticker('BTC/USDT'));
print_r($ticker); // Live updates!
}
await($exchange->close());
```
## REST vs WebSocket
| Mode | REST | WebSocket |
|------|------|-----------|
| **Sync** | `\ccxt\binance()` | (WebSocket requires async) |
| **Async** | `\ccxt\async\binance()` | `\ccxt\pro\binance()` |
| Feature | REST API | WebSocket API |
|---------|----------|---------------|
| **Use for** | One-time queries, placing orders | Real-time monitoring, live price feeds |
| **Method prefix** | `fetch_*` (fetch_ticker, fetch_order_book) | `watch_*` (watch_ticker, watch_order_book) |
| **Speed** | Slower (HTTP request/response) | Faster (persistent connection) |
| **Rate limits** | Strict (1-2 req/sec) | More lenient (continuous stream) |
| **Best for** | Trading, account management | Price mon