This is the unofficial client library for the GDAX API. Inspired by Coinbase PHP Library.
Install the library using Composer. Please read the Composer Documentation if you are unfamiliar with Composer or dependency managers in general.
composer require hellovoid/gdax
Use an API key, secret and passphrase to access your own GDAX account.
use Hellovoid\Gdax\Configuration;
use Hellovoid\Gdax\Client;
$configuration = Configuration::apiKey($apiKey, $apiSecret, $apiPassphrase);
$client = Client::create($configuration);
Every successful method request returns decoded json array.
Pagination #ref
Your requests should use these cursor values when making requests for pages after the initial request.
Parameter | Description |
---|---|
$before | Request page before (newer) this pagination id. (default null) |
$after | Request page after (older) this pagination id. (default null) |
$limit | Number of results per request. Maximum 100. (default 100) |
use \Hellovoid\Gdax\Pagination;
$pagination = Pagination::create($before, null, $limit);
$client->setPagination($pagination);
$pagination->setEndingBefore(null);
$pagination->setStartingAfter($after);
Accounts #ref
$client->getAccounts();
$client->getAccount($accountId);
$client->getAccountHistory($accountId);
$client->getAccountHolds($accountId);
Orders #ref
$order = $client->placeOrder([
'size' => 0.1,
'price' => 0.1,
'side' => 'buy',
'product_id' => 'BTC-USD'
]);
try {
$response = $client->orderCancel($orderId);
} catch (HttpException $e) { // Order could not be canceled
$e->getMessage();
}
$response = $client->ordersCancel();
Cancel all orders for a specific product:
$response = $client->ordersCancel([
'product_id' => $productId
]);
$response = $client->getOrders();
$response = $client->getOrder($orderId);
Fills #ref
$response = $client->getFills([
'order_id' => 'all',
'product_id' => 'all'
]);
Funding #ref
Get fundings with status "settled".
$response = $client->getFundings([
'status' => 'settled', // outstanding, settled, or rejected
]);
$response = $client->fundingRepay([
'amount' => 1.00,
'currency' => 'EUR',
]);
Margin Transfer #ref
$response = $client->marginTransfer([
'margin_profile_id' => '45fa9e3b-00ba-4631-b907-8a98cbdf21be',
'type' => 'deposit',
'currency' => 'USD',
'amount' => 2,
]);
Position #ref
$response = $client->position();
$response = $client->positionClose([
'repay_only' => true
]);
Deposits #ref
$response = $client->depositPaymentMethod([
'amount' => 2.00,
'currency' => 'USD',
'payment_method_id' => 'bc677162-d934-5f1a-968c-a496b1c1270b'
]);
Deposit funds from a coinbase account.
$response = $client->depositCoinbase([
'amount' => 2.00,
'currency' => 'BTC',
'coinbase_account_id' => 'c13cd0fc-72ca-55e9-843b-b84ef628c198'
]);
Withdrawals #ref
$response = $client->withdrawalPaymentMethod([
'amount' => 2.00,
'currency' => 'USD',
'payment_method_id' => 'bc677162-d934-5f1a-968c-a496b1c1270b'
]);
Withdrawal funds to a coinbase account.
$response = $client->withdrawalCoinbase([
'amount' => 2.00,
'currency' => 'BTC',
'coinbase_account_id' => 'c13cd0fc-72ca-55e9-843b-b84ef628c198'
]);
Withdrawal funds to a crypto address.
$response = $client->withdrawalCoinbase([
'amount' => 0.01,
'currency' => 'BTC',
'crypto_address' => '0x5ad5769cd04681FeD900BCE3DDc877B50E83d469'
]);
Payment methods #ref
Get a list of your payment methods.
$response = $client->getPaymentMethods();
Coinbase accounts #ref
Get a list of your coinbase accounts.
$response = $client->getCoinbaseAccounts();
Reports #ref
$response = $client->createReport([
'type' => 'fills',
'start_date' => '2014-11-01T00:00:00.000Z',
'end_date' => '2014-11-30T23:59:59.000Z'
]);
$response = $client->getReportStatus($reportId);
Products #ref
$response = $client->getProducts();
$response = $client->getProductOrderBook($productId);
$response = $client->getProductTicker($productId);
$response = $client->getProductTrades($productId);
$response = $client->getProductHistoricRates($productId);
$response = $client->getProductLast24HrStats($productId);
Currencies #ref
$response = $client->getCurrencies();
Get Time #ref
$response = $client->getTime();