Skip to content

Commit c4b459b

Browse files
author
DESKTOP\Kostadin
committed
Adding TradingApis
1 parent b3ab26d commit c4b459b

File tree

5 files changed

+545
-1
lines changed

5 files changed

+545
-1
lines changed

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,80 @@ $result = $instance->transactionApiBtcNewTransactionHdWallet()->create(Constants
370370
* $result = $instance->webhookBtcDeleteWebhooks()->delete(Constants::$BTC_TESTNET, 'UUID');
371371
*/
372372

373+
374+
/*
375+
* https://docs.cryptoapis.io/rest-apis/trading-apis/exchange-accounts/index#create-account
376+
* $result = $instance->tradingApisExchangeAccount()->create('binance','fasdfasgeag4gsee4vgsebgse4bbge4sbgsg4segs4e623676rhdht456589857f','fasdfasgeag4gsee4vgsebgse4bbge4sbgsg4segs4e623676rhdht456589857f','fasdfasgeag4gsee4vgsebgse4bbge4sbgsg4segs4e623676rhdht456589857f','asdsad');
377+
*/
378+
379+
/*
380+
* https://docs.cryptoapis.io/rest-apis/trading-apis/exchange-accounts/index#list-all-accounts
381+
* $result = $instance->tradingApisExchangeAccount()->listAll();
382+
*/
383+
384+
/*
385+
* https://docs.cryptoapis.io/rest-apis/trading-apis/exchange-accounts/index#get-account
386+
* $result = $instance->tradingApisExchangeAccount()->get('ebf4cbbf-3759-4b63-84c1-01bcf508317c');
387+
*/
388+
389+
/*
390+
* https://docs.cryptoapis.io/rest-apis/trading-apis/exchange-accounts/index#update-account
391+
* $result = $instance->tradingApisExchangeAccount()->update('ebf4cbbf-3759-4b63-84c1-01bcf508317c','binance','fasdfasgeag4gsee4vgsebgse4bbge4sbgsg4segs4e623676rhdht456589857f','fasdfasgeag4gsee4vgsebgse4bbge4sbgsg4segs4e623676rhdht456589857f','fasdfasgeag4gsee4vgsebgse4bbge4sbgsg4segs4e623676rhdht456589857f','asdsad');
392+
*/
393+
394+
/*
395+
* https://docs.cryptoapis.io/rest-apis/trading-apis/exchange-accounts/index#replace-account
396+
* $result = $instance->tradingApisExchangeAccount()->replace('ebf4cbbf-3759-4b63-84c1-01bcf508317c','binance','fasdfasgeag4gsee4vgsebgse4bbge4sbgsg4segs4e623676rhdht456589857f','fasdfasgeag4gsee4vgsebgse4bbge4sbgsg4segs4e623676rhdht456589857f','fasdfasgeag4gsee4vgsebgse4bbge4sbgsg4segs4e623676rhdht456589857f','asdsad');
397+
*/
398+
399+
/*
400+
* https://docs.cryptoapis.io/rest-apis/trading-apis/exchange-accounts/index#delete-account
401+
* $result = $instance->tradingApisExchangeAccount()->delete('ebf4cbbf-3759-4b63-84c1-01bcf508317c');
402+
*/
403+
404+
/*
405+
* https://docs.cryptoapis.io/rest-apis/trading-apis/private-apis/index#list-all-exchanges
406+
* $result = $instance->tradingApisPrivate()->listAll();
407+
*/
408+
409+
/*
410+
* https://docs.cryptoapis.io/rest-apis/trading-apis/private-apis/index#balance
411+
* $result = $instance->tradingApisPrivate()->getBalance('ebf4cbbf-3759-4b63-84c1-01bcf508317c');
412+
*/
413+
414+
/*
415+
* https://docs.cryptoapis.io/rest-apis/trading-apis/private-apis/index#get-deposit-address
416+
* $result = $instance->tradingApisPrivate()->getDepositAddress('ebf4cbbf-3759-4b63-84c1-01bcf508317c','dasd');
417+
*/
418+
419+
420+
/*
421+
* https://docs.cryptoapis.io/rest-apis/trading-apis/private-apis/index#get-my-trades
422+
* $result = $instance->tradingApisPrivate()->getMyTrades('ebf4cbbf-3759-4b63-84c1-01bcf508317c');
423+
*/
424+
425+
/*
426+
* https://docs.cryptoapis.io/rest-apis/trading-apis/private-apis/index#get-open-orders
427+
* $result = $instance->tradingApisPrivate()->getOpenOrders('ebf4cbbf-3759-4b63-84c1-01bcf508317c');
428+
*/
429+
430+
/*
431+
* https://docs.cryptoapis.io/rest-apis/trading-apis/private-apis/index#create-order
432+
* $result = $instance->tradingApisPrivate()->createOrder('ebf4cbbf-3759-4b63-84c1-01bcf508317c','btc/eth','market','buy',123,123);
433+
*/
434+
435+
436+
/*
437+
* https://docs.cryptoapis.io/rest-apis/trading-apis/private-apis/index#cancel-order
438+
* $result = $instance->tradingApisPrivate()->cancelOrder('ebf4cbbf-3759-4b63-84c1-01bcf508317c','asd','btc/eth');
439+
*/
440+
441+
442+
/*
443+
* https://docs.cryptoapis.io/rest-apis/trading-apis/private-apis/index#withdraw
444+
* $result = $instance->tradingApisPrivate()->withdraw('account_id','code','123','address');
445+
*/
446+
373447
```
374448

375449
## License

src/RestApis/Factory.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,4 +2114,20 @@ public function webhookEthDeleteWebhooks() {
21142114
return $this->getInstance($className);
21152115
}
21162116

2117+
/**
2118+
* @return \RestApis\TradingApis\ExchangeAccounts\Account
2119+
*/
2120+
public function tradingApisExchangeAccount() {
2121+
$className = 'RestApis\\TradingApis\\ExchangeAccounts\\Account';
2122+
return $this->getInstance($className);
2123+
}
2124+
2125+
/**
2126+
* @return \RestApis\TradingApis\PrivateApis\PrivateApis
2127+
*/
2128+
public function tradingApisPrivate() {
2129+
$className = 'RestApis\\TradingApis\\PrivateApis\\PrivateApis';
2130+
return $this->getInstance($className);
2131+
}
2132+
21172133
}
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
<?php
2+
3+
namespace RestApis\TradingApis\ExchangeAccounts;
4+
5+
use Common\Request;
6+
use Common\Response;
7+
8+
class Account extends Request {
9+
10+
protected $endpoint = '/trading/exchange-accounts';
11+
12+
/**
13+
* @param $exchange_id string
14+
* @param $exchange_api_key string
15+
* @param $exchange_secret string
16+
* @param $exchange_password string
17+
* @param $exchange_uid string
18+
* @return \stdClass
19+
*/
20+
public function create($exchange_id, $exchange_api_key, $exchange_secret = null, $exchange_password = null, $exchange_uid = null)
21+
{
22+
$params = [
23+
'url' => $this->getEndPoint(),
24+
'exchange_id' => $exchange_id,
25+
'exchange_api_key' => $exchange_api_key
26+
];
27+
28+
if(!is_null($exchange_secret)) {
29+
$params['exchange_secret'] = $exchange_secret;
30+
}
31+
32+
if(!is_null($exchange_password)) {
33+
$params['exchange_password'] = $exchange_password;
34+
}
35+
36+
if(!is_null($exchange_uid)) {
37+
$params['exchange_uid'] = $exchange_uid;
38+
}
39+
40+
return (new Response(
41+
$this->request([
42+
'method' => 'POST',
43+
'params' => $params
44+
])
45+
))->get();
46+
}
47+
48+
/**
49+
* @return \stdClass
50+
*/
51+
public function listAll()
52+
{
53+
$params = [];
54+
return (new Response(
55+
$this->request([
56+
'method' => 'GET',
57+
'params' => $params
58+
])
59+
))->get();
60+
}
61+
62+
63+
/**
64+
* @param $account_id string
65+
* @return \stdClass
66+
*/
67+
public function get($account_id)
68+
{
69+
$params = [];
70+
return (new Response(
71+
$this->request([
72+
'method' => 'GET',
73+
'params' => $params
74+
],
75+
$this->getEndPoint() . '/' . $account_id)
76+
))->get();
77+
}
78+
79+
/**
80+
* @param $account_id string
81+
* @param $exchange_id string
82+
* @param $exchange_api_key string
83+
* @param $exchange_secret string
84+
* @param $exchange_password string
85+
* @param $exchange_uid string
86+
* @return \stdClass
87+
*/
88+
public function update($account_id, $exchange_id = null, $exchange_api_key = null, $exchange_secret = null, $exchange_password = null, $exchange_uid = null)
89+
{
90+
$params = [];
91+
92+
if(!is_null($exchange_id)) {
93+
$params['exchange_id'] = $exchange_id;
94+
}
95+
96+
if(!is_null($exchange_api_key)) {
97+
$params['exchange_api_key'] = $exchange_api_key;
98+
}
99+
100+
if(!is_null($exchange_secret)) {
101+
$params['exchange_secret'] = $exchange_secret;
102+
}
103+
104+
if(!is_null($exchange_password)) {
105+
$params['exchange_password'] = $exchange_password;
106+
}
107+
108+
if(!is_null($exchange_uid)) {
109+
$params['exchange_uid'] = $exchange_uid;
110+
}
111+
112+
return (new Response(
113+
$this->request([
114+
'method' => 'PATCH',
115+
'params' => $params
116+
],$this->getEndPoint() . '/' . $account_id)
117+
))->get();
118+
}
119+
120+
/**
121+
* @param $account_id string
122+
* @param $exchange_id string
123+
* @param $exchange_api_key string
124+
* @param $exchange_secret string
125+
* @param $exchange_password string
126+
* @param $exchange_uid string
127+
* @return \stdClass
128+
*/
129+
public function replace($account_id, $exchange_id, $exchange_api_key, $exchange_secret = null, $exchange_password = null, $exchange_uid = null)
130+
{
131+
$params = [
132+
'exchange_id' => $exchange_id,
133+
'exchange_api_key' => $exchange_api_key
134+
];
135+
136+
if(!is_null($exchange_secret)) {
137+
$params['exchange_secret'] = $exchange_secret;
138+
}
139+
140+
if(!is_null($exchange_password)) {
141+
$params['exchange_password'] = $exchange_password;
142+
}
143+
144+
if(!is_null($exchange_uid)) {
145+
$params['exchange_uid'] = $exchange_uid;
146+
}
147+
148+
149+
return (new Response(
150+
$this->request([
151+
'method' => 'PUT',
152+
'params' => $params
153+
],$this->getEndPoint() . '/' . $account_id)
154+
))->get();
155+
}
156+
157+
/**
158+
* @param $account_id string
159+
* @return \stdClass
160+
*/
161+
public function delete($account_id)
162+
{
163+
$params = [];
164+
return (new Response(
165+
$this->request([
166+
'method' => 'DELETE',
167+
'params' => $params
168+
],
169+
$this->getEndPoint() . '/' . $account_id)
170+
))->get();
171+
}
172+
}

0 commit comments

Comments
 (0)