-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
fetch order
github-actions[bot] edited this page Jun 11, 2026
·
2 revisions
<?php
include './ccxt.php';
date_default_timezone_set('UTC');
$id = 'livecoin'; // edit this line
// ----------------------------------------------------------------------------
// instantiate the exchange by id
$exchange_class = '\\ccxt\\' . $id;
$exchange = new $exchange_class(array(
// some exchanges may require additional API credentials
'apiKey' => 'YOUR_API_KEY', // edit this line
'secret' => 'YOUR_SECRET', // edit this line
// this is not required! uncomment only if you want to debug it
// 'verbose' => true,
));
// ----------------------------------------------------------------------------
if ($exchange->has['fetchOrder'] === false) {
echo $exchange->id . " does not support fetchOrder() yet\n";
exit();
} else if ($exchange->has['fetchOrder'] === 'emulated') {
echo $exchange->id . " fetchOrder() is 'emulated' and relies " .
"on the `.orders` cache as described in the Manual:\n" .
"https://github.com/ccxt/ccxt/wiki/Manual#orders-cache\n";
exit();
}
// ----------------------------------------------------------------------------
if ($exchange->has['fetchOrder'] === true) {
// this is the order id returned from by any of the order API methods
// createOrder(), fetchOrders(), fetchOpenOrders(), fetchClosedOrders()
$order_id = '45125111901'; // edit this line
// most of exchanges will not require the symbol argument, but some of
// the exchanges will require it, and it's safe to always pass the
// symbol argument to fetchOrder along with the order id
$symbol = 'ETH/BTC'; // edit this line
// these params are exchange-specific, most of exchanges don't require them
// some exchanges or methods may require this or that parameter in certain
// cases, consult the exchanges' API docs to get a list of all params
$params = array(
// 'param1' => 'value1', // uncomment and edit if necessary
// 'param2' => 'value2', // uncomment and edit if necessary
);
try {
$order = $exchange->fetch_order($order_id, $symbol, $params);
print_r($order);
} catch (\ccxt\NetworkError $e) {
// in case of a networking or a connectivity error instead of simply
// printing the error message here, the application should define
// the behavior or a recover-and-retry strategy, because networking
// errors are temporary and occasionally happen with all exchanges
// a retry after a while may be enough, depending on the error
echo get_class ($e) . ': ' . $e->getMessage() . "\n";
} catch (\ccxt\ExchangeError $e) {
// in case of an exchange error the application should stop and signal
// the error to the developer or to the user, human interference is
// required to resolve an exchange error in each specific case
echo get_class($e) . ': ' . $e->getMessage() . "\n";
} catch (Exception $e) {
echo get_class($e) . ': ' . $e->getMessage() . "\n";
}
}(If the page is not being rendered for you, you can refer to the mirror at https://docs.ccxt.com/)
- Install
- Examples
- Manual
- CCXT Pro
- Contributing
- Supported Exchanges
- Exchanges By Country
- API Spec By Method
- FAQ
- Changelog
- Awesome
- API Spec by Exchange
- fetchCurrencies
- alpaca
- apex
- ascendex
- aster
- backpack
- bigone
- binance
- bingx
- bit2c
- bitbank
- bitbns
- bitfinex
- bitflyer
- bitget
- bithumb
- bitmart
- bitmex
- bitopro
- bitrue
- bitso
- bitstamp
- bitteam
- bittrade
- bitvavo
- blockchaincom
- blofin
- btcbox
- btcmarkets
- btcturk
- bullish
- bybit
- bydfi
- cex
- coinbase
- coinbaseexchange
- coinbaseinternational
- coincheck
- coinex
- coinmate
- coinmetro
- coinone
- coinsph
- coinspot
- cryptocom
- cryptomus
- deepcoin
- delta
- deribit
- derive
- digifinex
- dydx
- exmo
- extended
- foxbit
- gate
- gemini
- grvt
- hashkey
- hibachi
- hitbtc
- hollaex
- htx
- hyperliquid
- independentreserve
- indodax
- kraken
- krakenfutures
- kucoin
- fetchBidsAsks
- latoken
- lbank
- lighter
- luno
- mercado
- mexc
- modetrade
- ndax
- novadax
- okx
- onetrading
- p2b
- pacifica
- paradex
- paymium
- phemex
- poloniex
- tokocrypto
- toobit
- upbit
- weex
- whitebit
- woo
- woofipro
- xt
- zaif
- fetchStatus