公共API方法

有6种接受JSON格式的HTTP GET请求和返回响应的公共方法:

ReturnTicker

此方法为所有/指定市场股票回报;请求和响应的示例:

示例1: 所有股份回报。

请求: https://api.crex24.com/CryptoExchangeService/BotPublic/ReturnTicker

回复:

{
  Tickers: [{
    BaseVolume: "0.00000000",
    HighPrice: "0.09611615",
    Last: "0.05125186",
    LowPrice: "0.04456261",
    ...
  },  {
    BaseVolume: "0.00000000",
    HighPrice: "0.02062280",
    Last: "0.01025148",
    LowPrice: "0.00972667",
    ...
  },  {
    BaseVolume: "0.00000000",
    HighPrice: "0.00105385",
    Last: "0.00050066",
    LowPrice: "0.00040122",
    ...
  },  ...]
}

示例2: BTC_LTC和 BTC_DOGE交易回报。

请求: https://api.crex24.com/CryptoExchangeService/BotPublic/ReturnTicker?request=[NamePairs=BTC_LTC,BTC_DOGE]

回复:

{
  Tickers:  [{
    BaseVolume: "0.00000000",
    HighPrice: "0.02062280",
    Last: "0.01023842",
    LowPrice: "0.00972667",
    ...
  },  {
    BaseVolume: "0.47617000",
    HighPrice: "0.00000080",
    Last: "0.00000041",
    LowPrice: "0.00000035",
    ...
  }]
}


Return24Volume

此方法为所有/指定市场的24小时交易量回报:

示例: BTC_DOGE批量回报。

请求:https://api.crex24.com/CryptoExchangeService/BotPublic/Return24Volume?request=[NamePairs=BTC_DOGE]

回复:

{
  Volume: {
    VolumesByOne: [{
      Name: "BTC",
      Volume: 0.23673
    }, {
      Name: "DOGE",
      Volume: 577000
    }],
    VolumesByTwo: [{
      First: {
        Name: "BTC",
        Volume: 0.23673
      },
      Name: "BTC_DOGE",
      Second: {
        Name: "DOGE",
        Volume: 577000
      }
    }]
  }
}


ReturnOrderBook

此方法为指定市场的订单群回报

示例: BTC_DOGE订单群回报。

请求:https://api.crex24.com/CryptoExchangeService/BotPublic/ReturnOrderBook?request=[PairName=BTC_DOGE]

回复:

{
  BuyOrders: [{
    AccumulateMoneyCount: "36826.27800846",
    AccumulateMoneyVolume: "0.01509877",
    CoinCount: "36826.27800846",
    ...
  },  {
    AccumulateMoneyCount: "67304.76798074",
    AccumulateMoneyVolume: "0.02729017",
    CoinCount: "30478.48997228",
    ...
  },  {
    AccumulateMoneyCount: "75084.76074510",
    AccumulateMoneyVolume: "0.03032437",
    CoinCount: "7779.99276436",
    ...
  },  {
    AccumulateMoneyCount: "75433.94286209",
    AccumulateMoneyVolume: "0.03045706",
    CoinCount: "349.18211699",
    ...
  }],
  SellOrders: [{
    AccumulateMoneyCount: "10642.66536957",
    AccumulateMoneyVolume: "0.00446992",
    CoinCount: "10642.66536957",
    ...
  },  {
    AccumulateMoneyCount: "31738.44031685",
    AccumulateMoneyVolume: "0.01354110",
    CoinCount: "21095.77494728",
    ...
  }, {
    AccumulateMoneyCount: "41156.60557210",
    AccumulateMoneyVolume: "0.01768510",
    CoinCount: "9418.16525525",
    ...
  }, {
    AccumulateMoneyCount: "50937.97566773",
    AccumulateMoneyVolume: "0.02208671",
    CoinCount: "9781.37009563",
    ...
  }]
}


ReturnTradeHistoryPub

此方法为过去1000笔(或更少,根据指定计数参数)交易回报,或为UNIX时间戳格式的StartTS和EndTS参数指定的时间段中的交易回报。

示例: BTC_DPGE交易历史回报。

请求:https://api.crex24.com/CryptoExchangeService/BotPublic/ReturnTradeHistoryPub?request=[PairName=BTC_DOGE]

回复:

{
  Trades: [{
    CoinCount: "716.23394813",
    CoinPrice: "0.00000037",
    Commission: "0.00000027",
    DtCreateTS: 1502771794,
    ...
  }, {
    CoinCount: "283.76605187",
    CoinPrice: "0.00000037",
    Commission: "0.00000010",
    DtCreateTS: 1502771794,
    ...
  }]
}


ReturnChartData

此方法为指定市场的蜡烛图数据回报。以分钟为单位的蜡烛图时间可以通过CandleTimeInMinutes参数设定,开始和结束的间隔可以通过UNIX时间戳格式的StartTS和EndTS参数设定。

示例: 此方法重现2019年1月1日至31日期间BTC-DOGE的每日报价表。

请求:https://api.crex24.com/CryptoExchangeService/BotPublic/ReturnChartData?request=[PairName=BTC_DOGE][CandleTimeInMinutes=1440][StartTS=1546300800][EndTS=1548892800]

回复:

{
  Candles:  [{
    EndOrderPrice: "0.00000099",
    MaxOrderPrice: "0.00000100",
    MinOrderPrice: "0.00000098",
    OrderCount: 4,
    ...
  },  {
    EndOrderPrice: "0.00000100",
    MaxOrderPrice: "0.00000101",
    MinOrderPrice: "0.00000099",
    OrderCount: 2,
    ...
  },  {
    EndOrderPrice: "0.00000102",
    MaxOrderPrice: "0.00000103",
    MinOrderPrice: "0.00000100",
    OrderCount: 4 ,
    ...
  },  ...]
}


ReturnCurrencies

此方法反馈所有/指定货币的信息。

示例: 关于DOGE货币的信息

请求:https://api.crex24.com/CryptoExchangeService/BotPublic/ReturnCurrencies?request=[Names=DOGE]

回复:

{
  Currencies: [{
    Delisted: false,
    Disabled: false,
    Frozen: false,
    MinConf: 6,
    Name: "Dogecoin",
    ...
  }]
}

交易API方法

用于API交易的Url:https://api.crex24.com/CryptoExchangeService/BotTrade/<MethodName>

需创建API密钥以使用交易API(https://crex24.com/settings/tokens).

请注意默认限制为每秒6个请求。如果不够,请联系客户支持团队讨论提高限制事宜。

所有交易API请求都通过POST方法发送至HTTP地址,并需包含以下标头:
  • UserKey — API key.
  • 签名 - 通过HMACSHA512方法创建的POST机构请求的签名。

所有请求需包含POST参数Nonce。Nonce是无符号且必须大于先前值的int64值。您可以使用时间戳参数完成操作。

已经以JSON格式发送响应。若出现错误,响应将以下列格式呈现:

{"Error" : {"Message" : "<error message>"}}

以不同的编程语言发送到交易API的请求示例:

Readme: https://github.com/iiw/Crex24.Examples

Python: https://github.com/iiw/Crex24.Examples/blob/master/python/app.py

C#: https://github.com/3P3C/Crex24.Example/blob/master/Crex24Example/Program.cs

JS: https://github.com/iiw/Crex24.Examples/tree/master/js

PHP: https://github.com/iiw/Crex24.Examples/blob/master/php/app.php

ReturnBalances

获得可用余额。

示例:

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/ReturnBalances

请求主体:

{
    "Names" : ["BTC", "LTC"],    # 货币清单。若没有,则调取所有货币。
    "NeedNull" : "true"          # 在清单中包括零余额。
}

响应:

{
  "Balances": [
    {
      "AvailableBalances": 10.00000000,
      "InOrderBalances": 10.00000000,
      "Name": "BTC"
    },
    {
      "AvailableBalances": 0.00000000,
      "InOrderBalances": 0.00000000,
      "Name": "LTC"
    }
  ]
}

ReturnOpenOrders

获得开放订单。

示例:

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/ReturnOpenOrders

请求主体:

{
  "Pairs": ["BTC_LTC", "BTC_ETH"]    # 交易对清单。若没有,则调取所有交易对。
}

响应:

{
  "Orders": [
    {
      "CoinCount": 1.00000000,
      "CoinPrice": 0.01135442,
      "Id": 71463796,
      "IsCloseRequired": false,
      "IsSell": true,
      "PairName": "BTC_LTC"
    },
    {
      "CoinCount": 1.00000000,
      "CoinPrice": 0.06835904,
      "Id": 71463169,
      "IsCloseRequired": false,
      "IsSell": true,
      "PairName": "BTC_ETH"
    },
    ...
  ]
}

ReturnTradeHistory

获得交易历史。

示例:

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/ReturnTradeHistory

请求主体:

{
  "Pairs": ["BTC_LTC", "BTC_ETH"]   # 交易对清单。若没有,则调取所有交易对。
}

响应:

{
  "Trades": [
    {
      "CoinCount": 1.00000000,
      "CoinPrice": 0.06835904,
      "Commission": 0.00000166,
      "DtCreateTS": 1506517638,
      "Id": 185197,
      "IsMaker": true,
      "IsSell": true,
      "PairName": "BTC_ETH"
    },
    {
      "CoinCount": 1.00000000,
      "CoinPrice": 0.01135442,
      "Commission": 0.00000166,
      "DtCreateTS": 1506085177,
      "Id": 185169,
      "IsMaker": true,
      "IsSell": false,
      "PairName": "BTC_LTC"
    },
    ...
  ]
}

ReturnOrderTrades

按订单获取所有交易业务。

示例:

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/ReturnOrderTrades

请求主体:

{
  "OrderId": 51893150
}

响应:

{
  "Trades": [
    {
      "CoinCount": 10.00000000,
      "CoinPrice":  0.06835904,
      "Commission": 0.00000166,
      "DtCreateTS": 1506517638,
      "Id": 185197,
      "IsMaker": true,
      "IsSell": true,
      "PairName": "BTC_ETH"
    },
    ...
  ]
}

Buy

请下单购买。

示例: 请下订单以0.01194538的价格用BTC购买10LTC:

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/Buy

请求主体:

{
  "Pair": "BTC_LTC",
  "Course": 0.01194538,
  "Volume": 10.0
}

响应:

{
  "Id": 51893288
}

Sell

请下单出售。

示例: 请下单以0.01194538的价格出售10LTC换取BTC:

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/Sell

请求主体:

{
  "Pair": "BTC_LTC",
  "Course": 0.01194538,
  "Volume": 10.0
}

响应:

{
  "Id": 51893294
}

CancelOrder

取消订单。

示例:

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/CancelOrder

请求主体:

{
  "OrderId": 51893294
}

响应:

{
  "Success": true
}

CancelOrderMulti

按id名单或交易对取消多个订单。

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/CancelOrderMulti

示例1: 按ID名单取消订单:

请求主体:

{
  "OrderIds": [51893293, 51893292]
}

示例2: 按交易对取消所有订单:

请求主体:

{
  "PairNames": ["BTC_ETH", "BTC_LTC"]
}

响应:

{
  "Success": true
}

ReturnOrderStatus

按订单获得信息和所有交易操作。

示例:

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/ReturnOrderStatus

请求主体:

{
  "OrderId": 51893312
}

响应:

{
  "CurrentOrder": {               # 当前订单状态。
    "CoinCount": 9.00000000,
    "CoinPrice": 0.01194538,
    "Id": 51893314,
    "IsCloseRequired": false,
    "IsSell": false,
    "PairName": "BTC_LTC"
  },
  "SourceOrder": {                # 初始订单状态。
    "CoinCount": 10.00000000,
    "CoinPrice": 0.01194538,
    "Id": 51893314,
    "IsCloseRequired": false,
    "IsSell": false,
    "PairName": "BTC_LTC"
  },
  "Trades": [                     # 按照订单的交易操作清单。
    {
      "CoinCount": 1.00000000,
      "CoinPrice": 0.01194538,
      "Commission": 0.00000000,
      "DtCreateTS": 1507465556,
      "Id": 185250,
      "IsMaker": true,
      "IsSell": false,
      "PairName": "BTC_LTC"
    }
  ]
}

ReturnDepositsWithdrawals

获得存款和取款历史。交易将以页的形式显示,从最近的交易开始。若查看下一页,请用先前响应记录中的最低ID填写FromId字段。

示例: 获得过去100条记录:

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/ReturnDepositsWithdrawals

请求主体:

{
  "Names": ["BTC", "LTC"],       # 货币清单。若没有,则调取所有货币。
  "FromId": 0,                   # 先前响应记录中的0或最低的ID号。
  "Take": 100                    # 需返回的记录数量。最多记录数量为1000。
}

响应:

{
  "CountRemain": 1000,                          # 剩余记录的数量。若为0,则已到最后一页。
  "Changes": [
    {
      "Address": "17XjwyX78jusTPXHxxF14ST9fWrCUcLT6L",   # 支付地址。
      "AgentName": null,                        # 法定货币支付系统名称。
      "CurrenceName": "BTC",
      "Id": 151,                                # 记录ID。
      "NeedConfirm": 15,
      "NumConfirm": 17,
      "Status": 3,                              # 支付状态。如下。
      "Sum": 0.20000000,
      "TimeTs": 1504100143,                     # UTC格式的记录创建时间。
      "TxId": "4f37855e4ecfc8f15b58f3397a6f339ca6f941d63d097c08004f7c9dfc4ec700",   # 交易ID
      "Type": 2                                 # 记录类型。如下。
    },
    ...
  ],
}

“状态”字段可能的值:
  1. - 经用户确认
  2. - 已创建交易
  3. - 第一次确认
  4. - 已成功受理
  5. - 交易已被拒绝
  6. - 处理中
  7. - 被用户取消
  8. - 等待发送
“类型”字段可能的值:
  1. - 加密货币存款
  2. - 加密货币提取
  3. - 法定货币存款
  4. - 法定货币取款

Withdraw

创建取款请求。

示例:

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/Withdraw

请求主体:

{
  "Currency": "BTC",
  "Sum": 1.0,
  "Address": "17XjwyX78jusTPXHxxF14ST9fWrCUcLT6L",
  "Message": "any_message"         # 交易消息(若货币支持,将被发送)。
}

响应:

{
  "NewBalance": 9.00000000,                         # 新余额。
  "OutId": 613                                      # 取款请求的Id。若不是0,请求已成功创建。
}

ReturnDepositAddress

获得地址存入货币。若需要为存款附加消息,将会在响应中出现。

请求: https://api.crex24.com/CryptoExchangeService/BotTrade/ReturnDepositAddress

示例1: 获得地址做BTC存款:

请求主体:

{
  "Currency": "BTC"
}

响应:

{
  "Address": "1JH6h3qDbAMEzAD8e7usWEqePddHzpSTgK",
  "Message": null 
}

示例2: 获得地址做XMR存款:

请求主体:

{
  "Currency": "XMR"
}

响应:

{
  "Address": "NC6GOUR4ICVVPPK7N4UIYWDJM6LTUBJFR7OVXDS5",
  "Message": "950a239c0f98ca41"                             # 存款是必须说明的消息。
}