NAV Navbar
  • Introduction
  • Authentication
  • Signing a Message
  • Time
  • Timestamps
  • Sequence Numbers
  • Time request
  • Accounts
  • Payment methods
  • Orders
  • Products
  • Withdrawals
  • Deposit
  • Introduction

    Welcome to the Abucoins API! You can use our API to access Abucoins API endpoints, which can get information about product, orders and fees.

    Rest api endpoint url

    https://api.abucoins.com

    Rate limits

    300 requests per 1 minute per IP and Account. When a rate limit is exceeded, a status of 429 will be returned.

    Authentication

    Generating an API Key

    Example class

    class Api
    {
        const API_URL = 'http://api.abucoins.com';
    
        protected $accesskey;
        protected $secret;
        protected $passphrase;
        protected $timestamp;
    
        public function __construct($settings)
        {
            $this->secret = $settings['secret'];
            $this->accesskey = $settings['access_key'];
            $this->passphrase = $settings['passphrase'];
            $this->timestamp = time();
        }
    
        public function jsonRequest($method, $path, $datas)
        {
            $this->timestamp = time();
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
            curl_setopt($ch, CURLOPT_URL, static::API_URL . "$path");
            if ($method == 'POST') {
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($datas));
            }
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'Content-Type: application/json',
                'AC-ACCESS-KEY: ' . $this->accesskey,
                'AC-ACCESS-TIMESTAMP: ' . $this->timestamp,
                'AC-ACCESS-PASSPHRASE: ' . $this->passphrase,
                'AC-ACCESS-SIGN: ' . $this->signature($path, $datas, $this->timestamp, $method),
            ));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $server_output = curl_exec($ch);
            curl_close($ch);
            return json_decode($server_output);
        }
    
        public function signature($request_path = '', $body = '', $timestamp = false, $method = 'GET')
        {
            $body = is_array($body) ? json_encode($body) : $body;
            $timestamp = $timestamp ? $timestamp : time();
            $what = $timestamp . $method . $request_path . $body;
            return base64_encode(hash_hmac("sha256", $what, base64_decode($this->secret), true));
        }
    
    }
    
    $configAbucoins = [
        'secret' => 'M1Y1N0oHZ2RSW7teVE5mbzB7xX0iP0NZS7x6LyVVUE1PsVMqV2hfNEBbUSYuWiQj',
        'access_key' => '10-30DWTDFOC17GE5IVL6ALUQBUN8Y4SF39',
        'passphrase' => '34y42c2bfce'
    ];
    
    $abucoinsApi = new AbucoinsApi($configAbucoins);
    $list = $abucoinsApi->jsonRequest('GET', '/orders', null);
    

    Abucoins expects for the API key to be included in all API requests to the server in a header that looks like the following:

    AC-ACCESS-KEY: Api key

    AC-ACCESS-SIGN: Sign of message (see Signing a Message)

    AC-ACCESS-TIMESTAMP: Current timestamp

    AC-ACCESS-PASSPHRASE

    Signing a Message

    AC-ACCESS-SIGN header is generated by creating a sha256 HMAC using the secret key(need to be base64-decoded) on the prehash string concatenation timestamp(in seconds) + method(GET/POST/DELETE) + requestPath(including query string like /producs/BTC-USD/book?level=2) + body and base64-encode the output. The timestamp value is the same as the AC-ACCESS-TIMESTAMP header.

    $string = $timestamp . $method . $request_path . $body;
    $sign = base64_encode(hash_hmac("sha256", $string, base64_decode($secret), true));
    

    Time

    The AC-ACCESS-TIMESTAMP header must be number of seconds since Unix Epoch in UTC. Only decimal values are allowed.

    Your timestamp must be maximum 30 seconds before or 30 seconds after api time. Otherwise your request will be rejected.

    Timestamps

    2014-11-06T10:34:47Z
    

    All timestamps from API are returned in ISO 8601.

    Sequence Numbers

    Most feed messages contain a sequence number. Sequence numbers are increasing integer values for each product with every new message being exactly 1 sequence number than the one before it.

    Time request

    Example response

    {
      "iso":"2017-10-10T11:16:50Z",
      "epoch":1507634210
    }
    

    Return current server time.

    HTTP Request

    GET /time

    Accounts

    List Accounts

    Example response

    [
        {
            "id": "3-BTC",
            "currency": "BTC",
            "balance": 13.38603805,
            "available": 13.38589212,
            "available_btc": 13.38589212,
            "hold": 0.00014593,
            "profile_id": 3
        },
        {
            "id": "3-ETH",
            "currency": "ETH",
            "balance": 133.48685448,
            "available": 133.48685448,
            "available_btc": 9.38012126,
            "hold": 0,
            "profile_id": 3
        }
    ]
    

    Get a list of trading accounts.

    HTTP Request

    GET /accounts

    Accounts fields

    Field Description
    id account id
    currency the currency of the account
    balance the founds in the account
    available founds available to withdraw or trade
    available_btc founds available to withdraw or trade for BTC
    hold funds on hold (not available for use)
    profile_id profile id

    Get an Account

    Information for a single account. Use this endpoint when you know the account_id.

    HTTP Request

    GET /accounts/<account-id>

    Field Description
    id account id
    currency the currency of the account
    balance the founds in the account
    available founds available to withdraw or trade
    available_btc founds available to withdraw or trade for BTC
    hold funds on hold (not available for use)
    profile_id profile id

    Payment methods

    List Payment Methods

    Example response

    [
        {
            "id": "sepa_pln",
            "type": "sepa_pln",
            "name": "PLN",
            "currency": "PLN",
            "allow_buy": true,
            "allow_sell": true,
            "allow_deposit": true,
            "allow_withdraw": true,
            "limits": {
                "buy": 10000,
                "sell": 10000,
                "deposit": 9223372036854775807,
                "withdraw": 9223372036854775807
            }
        },
        {
            "id": "bitcoin",
            "type": "bitcoin",
            "name": "Bitcoin",
            "currency": "BTC",
            "allow_buy": true,
            "allow_sell": true,
            "allow_deposit": true,
            "allow_withdraw": true,
            "limits": {
                "buy": 10000,
                "sell": 10000,
                "deposit": 5,
                "withdraw": 0.5
            }
        }
    ]    
    

    Get a list of your payment methods.

    HTTP Request

    GET /payment-methods

    Orders

    List Orders

    Example response

    [
        {
            "id": 7786713,
            "price": "0.05367433",
            "size": "0.10451686",
            "product_id": "ZEC-BTC",
            "side": "buy",
            "type": "limit",
            "time_in_force": "GTC",
            "post_only": false,
            "created_at": "2017-09-03T03:33:17Z",
            "filled_size": "0.00000000",
            "status": "closed",
            "settled": false
        },
        {
            "id": 7786713,
            "price": "0.05367433",
            "size": "0.10451686",
            "product_id": "ZEC-BTC",
            "side": "buy",
            "type": "limit",
            "time_in_force": "GTC",
            "post_only": false,
            "created_at": "2017-09-03T03:33:17Z",
            "filled_size": "0.00000000",
            "status": "closed",
            "settled": false
        }
    ]
    

    List your current orders.

    HTTP Request

    GET /orders

    QUERY PARAMETERS

    Field Default Description
    status [open, done] Limit list of orders to these statuses
    product_id ex. [ETH-BTC] Get orders for the specified market

    Get an Order

    Example response

    {
        "id": 7786714,
        "price": "0.05363803",
        "size": "0.91353089",
        "product_id": "ZEC-BTC",
        "side": "buy",
        "type": "limit",
        "time_in_force": "GTC",
        "post_only": false,
        "created_at": "2017-09-03T03:33:17Z",
        "filled_size": "0.00000000",
        "status": "closed",
        "settled": false
    }
    

    Get a single order by order id.

    HTTP Request

    GET /orders/<order-id>

    Create an Order

    Create new order

    HTTP Request

    POST /orders

    Example response

    {
        "status": "pending",
        "product_id": "ZEC-BTC",
        "used": 0,
        "size": 0.91353089,
        "price": 0.05363803,
        "id": "8634595",
        "side": "sell",
        "type": "limit",
        "time_in_force": "GTC",
        "post_only": false,
        "created_at": "2017-09-21T11:41:17Z",
        "filled_size": 0,
        "settled": false
    }
    

    Order fields

    Field Default Description
    product_id ex. ZEC-BTC Product id
    price Price of the current order
    size Amount of current product
    side buy, sell Operation type
    type limit, market Type of market offer
    time_in_force GTC [optional] GTC, GTT
    post_only false [optional] create order only if maker - true, false
    cancel_after [optional] min, hour, day

    Time in force

    Time in force policies provide guarantees about the lifetime of an order.

    GTC (Good Till Canceled) orders remain open on the book until canceled(default).

    GTT (Good Till Time) orders remain open on the book until canceled or the allotted cancel_after is depleted on the matching engine. GTT orders are guaranteed to cancel before any other order is processed after the cancel_after timestamp which is returned by the API. A day is considered 24 hours.

    Delete an single order

    Delete a single order by order id.

    HTTP Request

    DELETE /orders/<order-id>

    Delete all orders

    Delete all orders

    HTTP Request

    DELETE /orders

    QUERY PARAMETERS

    Field Default Description
    product_id ex. [ZEC-BTC] Optional parameter with product id

    List Fills

    Example response

    [
      {
        "trade_id":785705,
        "product_id":"BTC-PLN",
        "price":"14734.55000000",
        "size":"100.00000000",
        "order_id":4196245,
        "created_at":"2017-09-28T13:08:43Z",
        "liquidity":"T",
        "side":"sell"
      },
      {
        "trade_id":785704,
        "product_id":"BTC-PLN",
        "price":"14734.55000000",
        "size":"0.01000000",
        "order_id":4196245,
        "created_at":"2017-09-28T13:08:43Z",
        "liquidity":"T",
        "side":"sell"
      }
    ]
    

    Get a list of recent fills.

    HTTP Request

    GET /fills

    Response fields

    Field Description
    trade_id identifier of the last trade
    product_id product identifier
    price trade price
    size: trade size
    order_id Identifier of order
    created_at time in UTC
    liquidity indicates if the fill was the result of a liquidity provider or liquidity taker. M indicates Maker and T indicates Taker.
    side user side(buy or sell)

    Products

    List Products

    Example response

    [
        {
            "id": "ETH-BTC",
            "base_currency": "ETH",
            "quote_currency": "BTC",
            "base_min_size": "0.0010",
            "base_max_size": "100000.00000000",
            "quote_increment": "0.00000001",
            "display_name": "ETH/BTC"
        },
        {
            "id": "LTC-BTC",
            "base_currency": "LTC",
            "quote_currency": "BTC",
            "base_min_size": "0.0010",
            "base_max_size": "100000.00000000",
            "quote_increment": "0.00000001",
            "display_name": "LTC/BTC"
        },
        {
            "id": "ETC-BTC",
            "base_currency": "ETC",
            "quote_currency": "BTC",
            "base_min_size": "0.0010",
            "base_max_size": "100000.00000000",
            "quote_increment": "0.00000001",
            "display_name": "ETC/BTC"
        }
    ]
    

    Get a list of available currency pairs for trading.

    HTTP Request

    GET /products

    Response fields:

    Field Description
    id identifier of market
    base_currency which currency is buying/selling
    quote_currency price currency of base_currency
    base_min_size minimum order size
    base_max_size maximum order size
    quote_increment the order price must be a multiple of this increment

    Product

    Example response

    {
      "id": "ETH-BTC",
      "base_currency": "ETH",
      "quote_currency": "BTC",
      "base_min_size": "0.0010",
      "base_max_size": "100000.00000000",
      "quote_increment": "0.00000001",
      "display_name": "ETH/BTC"
    }
    

    Get a specific market product.

    HTTP Request

    GET /products/<product-id>

    product-id is market pair like BTC-USD, ETH-BTC etc.

    Response fields:

    Field Description
    id identifier of market
    base_currency which currency is buying/selling
    quote_currency price currency of base_currency
    base_min_size minimum order size
    base_max_size maximum order size
    quote_increment the order price must be a multiple of this increment

    Get Product Order Book

    Example response

    {
        "asks": [
          [ price, size, num-orders ],
          ["14160.13374000", "0.15994651", 1]
          ...
        ],
        "bids": [
           [ price, size, num-orders ],
           ["14140.00000000", "0.19970339", 1]
           ...
        ],
        "sequence": 1431
    }
    

    Example response for /products/BTC-PLN/book?level=2

    {
        "bids": [
            [ price, size, num-orders ],
        ],
        "asks": [
            [ price, size, num-orders ],
        ],
        "sequence": 1431
    }
    

    Return product orderbook

    HTTP Request

    GET /products/<product-id>/book

    By default, full agregated order book is returned. This is equivalent to a book depth of 0 level.

    Aggregated levels return only one size for each active price.

    Levels:

    GET /products/<product-id>/book?level=2

    Level Description
    0 fully agregated order book
    1 best ask and bid
    2 top 50 asks and bids

    Get Product Ticker

    Example response

    {
        "trade_id": "553612",
        "price": 14160.85,
        "size": 0.00053,
        "bid": "14140.00000000",
        "ask": "14181.70000000",
        "volume": "1.09596639",
        "time": "2017-09-21T10:26:58Z"
    }
    

    Snapshot information about the last trade (tick), best bid/ask and 24h volume.

    HTTP Request

    GET /products/<product-id>/ticker

    Response fields

    Field Description
    trade_id identifier of the last trade
    price last price
    size: size of the last trade
    bid the best bid
    ask the best ask
    valume 24 hour volume
    time time in UTC

    Get Trades

    Example response

    [
        {
            "time": "2017-09-21T12:33:03Z",
            "trade_id": 553794,
            "price": "14167.99328000",
            "size": "0.00035000",
            "side": "buy"
        },
        {
            "time": "2017-09-21T12:32:34Z",
            "trade_id": 553780,
            "price": "14163.96328000",
            "size": "0.00050000",
            "side": "buy"
        }
    ]    
    

    List the latest 100 trades for a product.

    Response fields:

    Field Description
    time time in UTC
    trade_id identifier of the last trade
    price last price
    size: size of the last trade
    side maker order side(sell or buy)

    HTTP Request

    GET /products/<product-id>/trades

    Pagination

    Parameter Default Description
    before Request page before (newer) this pagination id.
    after Request page after (older) this pagination id.
    limit 100 Number of results per request. Maximum 10000. (default 100)

    before and after cursors are available via response headers ac-before and ac-after. Your requests should use these cursor values when making requests for pages after the initial request.

    To get older information you would request pages after the initial page. To get information newer, you would request pages before the first page.

    Get Historic Rates

    Example response

    [
        [ time, low, high, open, close, volume ],
        [
            1505984400,
            "14209.92500000",
            "14209.92500000",
            "14209.92500000",
            "14209.92500000",
            0.001
        ],
        [
            1505984460,
            "14209.92500000",
            "14209.92500000",
            "14209.92500000",
            "14209.92500000",
            0.00052
        ],
        [
            1505984520,
            "14209.92500000",
            "14209.92500000",
            "14209.92500000",
            "14209.92500000",
            0.00068
        ]
    ]
    

    List the latest trades for a product.

    HTTP Request

    GET /products/<product-id>/candles?granularity=[granularity]&start=[UTC time of start]&end=[UTC time of end]

    QUERY PARAMETERS

    Param Description
    start Start time in ISO 8601
    end End time in ISO 8601
    granularity Desired timeslice in seconds

    Minimum start time is 30 days before current time.

    RESPONSE FIELDS

    time | low | high | open | close |volume

    Product stats

    Example response

    {
      "last":"14734.55000000",
      "open":"14734.55000000",
      "high":"0.00000000",
      "low":"0.00000000",
      "volume":"1.00000000"
    }
    

    Product stats

    HTTP Request

    GET /products/<product-id>/stats

    Global stats

    Example response

    [
      {
        "product_id":"BTC-PLN",
        "last":"14734.55000000",
        "open":"14734.55000000",
        "high":"0.00000000",
        "low":"0.00000000",
        "volume":"1.00000000",
        "volume_BTC":"1.00000000",
        "volume_USD":4086.69,
        "volume_7d":"0.00000000",
        "volume_30d":"149.45718835",
        "change":"0.00"
      },
      {
        "product_id":"BTC-USD",
        "last":"4086.69000000",
        "open":"4086.69000000",
        "high":"0.00000000",
        "low":"0.00000000",
        "volume":"1.00000000",
        "volume_BTC":"1.00000000",
        "volume_USD":4086.69,
        "volume_7d":"0.00000000",
        "volume_30d":"53.95784974",
        "change":"0.00"
      }
    ]
    

    List of the all products with stats.

    HTTP Request

    GET /products/stats

    Withdrawals

    Crypto

    Example request

    {
        "amount": 10.00,
        "currency": "BTC",
        "method": "bitcoin",
        "address": "0x5ad5769cd04681FeD900BCE3DDc877B50E83d469"
    }
    

    Example response

    {
        "status": 0,
        "message": "Your transaction is pending. Please confirm it via email.",
        "payoutId": "65",
        "balance": [
            {
                "type": "PLN",
                "balance": "2999990.00000000",
                "locked": "0.00000000"
            },
            {
                "type": "BTC",
                "balance": "13.38589212",
                "locked": "0.00014593"
            }
        ]
    }
    

    HTTP Request

    POST /withdrawals/crypto

    QUERY PARAMETERS

    Field Description
    amount The amount to withdraw
    currency The type of currency
    method Payment method
    address A crypto address of the recipient

    Deposit

    Crypto

    Gets an information about deposit address

    Example request

    {
        "currency": "XEM",
        "method": "nem"
    }
    

    Example response

    {
        "address": "NCYFDRHBAHYRWMZFRDAOXQ2KUGLD5AHHFC2J",
        "tag": "54b5fc2ae75afd20fd1514f8b5f6389dfb3f0"
    }
    

    HTTP Request

    POST /deposits/crypto

    QUERY PARAMETERS

    Field Description
    currency The type of currency
    method Payment method