Skip to content

Poloniex API Like the official document interface, Support for arbitrary extension.

License

Notifications You must be signed in to change notification settings

zhouaini528/poloniex-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

It is recommended that you read the official document first

Spot Document https://docs.poloniex.com/#cancelloanoffer

Future Document https://futures-docs.poloniex.com/#get-position-list

All interface methods are initialized the same as those provided by Poloniex. See details 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.

中文文档

Other exchanges API

Exchanges It includes all of the following exchanges and is highly recommended.

Bitmex Support Websocket

Okex Support Websocket

Huobi Support Websocket

Binance Support Websocket

Kucoin

Mxc

Coinbase

ZB

Bitfinex

Bittrex

Kraken

Gate

Bigone

Crex24

Bybit

Coinbene

Bitget

Poloniex

If you don't find the exchange SDK you want, you can tell me and I'll join them.

Installation

composer require linwj/poloniex

Support for more request Settings

$poloniex=new PoloniexSpot();
//or
$poloniex=new PoloniexFuture();

//You can set special needs
$poloniex->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,
]);

Spot API

Public API More

$poloniex=new PoloniexSpot();

try {
    $result=$poloniex->publics()->returnTicker();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->return24hVolume();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnOrderBook([
        'currencyPair'=>'BTC_ETH',
        'depth'=>'5',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnTradeHistory([
        'currencyPair'=>'BTC_ETH',
        'start'=>'1410158341',
        'end'=>'1410499372',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnChartData([
        'currencyPair'=>'USDT_BTC',
        'period'=>'1800',
        'start'=>'1410158341',
        'end'=>'1410499372',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

Private API More

$poloniex=new PoloniexSpot($key,$secret);

//account
try {
    $result=$poloniex->privates()->returnBalances();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->returnCompleteBalances();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->returnDepositAddresses();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->returnDepositsWithdrawals([
        'start'=>'1539954535',
        'end'=>'1540314535',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

//order
try {
    $result=$poloniex->privates()->buy([
        'currencyPair'=>'USDT_BTC',
        'rate'=>'5000',
        'amount'=>'0.1',
        'clientOrderId'=>'123456',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->cancelOrder([
        'orderNumber'=>'123456',//(Optional) The identity number of the order to be canceled.
        //'clientOrderId'=>'123456',//(Optional) User specified 64-bit integer identifier.
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->cancelAllOrders([
        'currencyPair'=>'USDT_BTC',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->marginBuy([
        'currencyPair'=>'USDT_BTC',
        'rate'=>'5000',
        'amount'=>'0.1',
        'lendingRate'=>'0.03',
        'clientOrderId'=>'123456',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->getMarginPosition([
        'currencyPair'=>'USDT_BTC',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->closeMarginPosition([
        'currencyPair'=>'USDT_BTC',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->cancelLoanOffer([
        'orderNumber'=>'123456',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

More Test

More Api

Future API

Market API More

$poloniex=new PoloniexFuture();
try {
    $result=$poloniex->publics()->returnTicker();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->return24hVolume();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnOrderBook([
        'currencyPair'=>'BTC_ETH',
        'depth'=>'5',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnTradeHistory([
        'currencyPair'=>'BTC_ETH',
        'start'=>'1410158341',
        'end'=>'1410499372',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnChartData([
        'currencyPair'=>'USDT_BTC',
        'period'=>'1800',
        'start'=>'1410158341',
        'end'=>'1410499372',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

Trade API More

$poloniex=new PoloniexFuture($key,$secret,$passphrase);
//order
try {
    $result=$poloniex->trade()->postOrders([
        'clientOid'=>'123456',
        'side'=>'buy',
        'symbol'=>'BTCUSDTPERP',
        'type'=>'market',
        'size'=>'20',
        //'quantity'=>'',
        'leverage'=>'20',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->deleteOrder([
        'order-id'=>'123456',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->deleteOrders([
        'symbol'=>'BTCUSDTPERP',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->getOrder([
        'order-id'=>'123456',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->getOrders([
        'status'=>'active',
        'symbol'=>'BTCUSDTPERP',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

//position
try {
    $result=$poloniex->trade()->getPosition([
        'symbol'=>'BTCUSDTPERP',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->getPositions();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->postPositionMarginAutoDepositStatus([
        'symbol'=>'BTCUSDTPERP',
        'status'=>true
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

User API More

$poloniex=new PoloniexFuture($key,$secret,$passphrase);

try {
    $result=$poloniex->user()->getAccountOverview([
        //'currency'=>'USDT'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->user()->getTransactionHistory();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

More Test

More Api

About

Poloniex API Like the official document interface, Support for arbitrary extension.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages