Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed May 13, 2020
1 parent 92c5aff commit 256a0e9
Show file tree
Hide file tree
Showing 2 changed files with 245 additions and 218 deletions.
185 changes: 184 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
### It is recommended that you read the official document first

Coinbase docs [https://docs.pro.coinbase.com](https://docs.pro.coinbase.com)

All interface methods are initialized the same as those provided by okex. See details [src/api](https://github.com/zhouaini528/coinbase-php/tree/master/src/Api)

Most of the interface is now complete, and the user can continue to extend it based on my design, working with me to improve it.

[中文文档](https://github.com/zhouaini528/coinbase-php/blob/master/README_CN.md)

### Other exchanges API

Expand All @@ -14,4 +20,181 @@

[Binance](https://github.com/zhouaini528/binance-php)

[Kucoin](https://github.com/zhouaini528/kucoin-php)
[Kucoin](https://github.com/zhouaini528/kucoin-php)

[Mxc](https://github.com/zhouaini528/Mxc-php) Temporarily not connected to Exchanges SDK

[Coinbase](https://github.com/zhouaini528/coinbase-php) Temporarily not connected to Exchanges SDK

#### Installation
```
composer require linwj/coinbase
```

Support for more request Settings
```php
$coinbase=new Coinbase();

//You can set special needs
$coinbase->setOptions([
//Set the request timeout to 60 seconds by default
'timeout'=>10,

//If you are developing locally and need an agent, you can set this
'proxy'=>true,
//More flexible Settings
/* 'proxy'=>[
'http' => 'http://127.0.0.1:12333',
'https' => 'http://127.0.0.1:12333',
'no' => ['.cn']
], */
//Close the certificate
//'verify'=>false,
]);
```

### Coinbase Spot API

Market related API [More](https://github.com/zhouaini528/coinbase-php/blob/master/tests/product.php)
```php
$coinbase=new Coinbase();

try {
$result=$coinbase->product()->getList();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

try {
$result=$coinbase->product()->getBook([
'product_id'=>'BTC-USD',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

try {
$result=$coinbase->product()->getCandles([
'product_id'=>'BTC-USD',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

```

Order related API [More](https://github.com/zhouaini528/coinbase-php/blob/master/tests/order.php)
```php
$coinbase=new Coinbase($key,$secret);

//****************************LIMIT
try {
$result=$coinbase->order()->post([
//'client_oid'=>'',
'type'=>'limit',
'side'=>'sell',
'product_id'=>'BTC-USD',
'price'=>'20000',
'size'=>'0.01'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
sleep(1);

//track the order
try {
$result=$coinbase->order()->get([
'id'=>$result['id'],
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
sleep(1);

//cancellation of order
try {
$result=$coinbase->order()->delete([
'id'=>$result['id'],
//'id'=>'6bad6a7d-b01a-4a93-9e6e-e9934bcef4ef',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

//****************************MARKET
try {
$result=$coinbase->order()->post([
//'client_oid'=>'',
'type'=>'market',
'side'=>'sell',
'product_id'=>'BTC-USD',
'size'=>'0.01',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
sleep(1);

//track the order
try {
$result=$coinbase->order()->get([
'id'=>$result['id'],
//'client_oid'=>''
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
```

Accounts related API [More]()
```php
$coinbase=new Coinbase($key,$secret);

try {
$result=$coinbase->account()->getList();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

try {
$result=$coinbase->account()->get([
'account_id'=>'c74a36f5-4f2b-495b-be29-6eb2458d1b3a'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

try {
$result=$coinbase->account()->getHolds([
'account_id'=>'c74a36f5-4f2b-495b-be29-6eb2458d1b3a'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

try {
$result=$coinbase->account()->getLedger([
'account_id'=>'c74a36f5-4f2b-495b-be29-6eb2458d1b3a'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

```

[More Test](https://github.com/zhouaini528/coinbase-php/tree/master/tests)

[More Api](https://github.com/zhouaini528/coinbase-php/tree/master/src/Api)
Loading

0 comments on commit 256a0e9

Please sign in to comment.