• BTC : ¥31980.00
  • LTC : ¥333.00
  • ETH : ¥1736.00
  • ETC : ¥63.01
  • QTUM : ¥41.50

比特儿API 2.0

1. 所有交易对 API

返回所有系统支持的交易对

URL: http://data.bter.com/api2/1/pairs

示例

    # Request
    GET: http://data.bter.com/api2/1/pairs
    # Response
    [
            "btc_cny","ltc_cny","xrp_cny","xrp_btc","bcc_cny",
            "bcc_btc","qtum_btc","qtum_eth","qtum_cny","etp_btc",
            "etp_cny","btrx_cny","btrx_btc","bts_cny","cnc_cny",
            "rep_cny","bat_cny","snt_cny","snt_btc","snt_eth",
            "btm_cny","btm_btc","omg_cny","omg_btc","omg_eth",
            "pay_cny","pay_btc","pay_eth","bat_eth","ico_cny",
            "ico_btc","ico_eth","eos_cny","eos_btc","eos_eth",
            "doge_cny","dash_cny","eth_cny","etc_cny","ftc_cny",
            "ifc_cny","nmc_cny","nxt_cny","ppc_cny","shell_cny",
            "tips_cny","tix_cny","xcp_cny","xmr_cny","xpm_cny",
            "xtc_cny","ltc_btc","bts_btc","cnc_btc","rep_btc",
            "bat_btc","hkg_btc","doge_btc","dash_btc","eth_btc",
            "etc_btc","ftc_btc","nmc_btc","nxt_btc","ppc_btc",
            "xtc_btc","xcn_btc","xcp_btc","xem_btc","xem_cny",
            "xpm_btc","xmr_btc","mg_btc","ifc_ltc","tips_ltc",
            "tix_ltc","etc_eth","zec_btc","zec_cny"
    ]
            

返回值说明

    btc_cny: 比特币对人民币交易
    Ltc_cny: 莱特币对人民币
    xrp_cny: 瑞波币对人民币
    xrp_btc: 瑞波币对比特币
    zec_cny: ZCash对人民币
    ……
    

2. 交易市场订单参数 API

返回所有系统支持的交易市场的参数信息,包括交易费,最小下单量,价格精度等。

URL: http://data.bter.com/api2/1/marketinfo

示例

    # Request
    GET: http://data.bter.com/api2/1/marketinfo
    # Response
   {
        "result": "true",
        "pairs": [
                    {
                    "btc_cny": {
                        "decimal_places": 2,
                        "min_amount": 0.5,
                        "fee": 0.2
                                }
                    },
                    {
                    "xrp_btc": {
                        "decimal_places": 7,
                        "min_amount": 0.0001,
                        "fee": 0.2
                                }
                    }
            ]
    }
            

返回值说明

    decimal_places: 价格精度
    min_amount : 最小下单量
    fee : 交易费

3. 交易市场详细行情 API

返回所有系统支持的交易市场的详细行情和币种信息,包括币种名,市值,供应量,最新价格,涨跌趋势,价格曲线等。

URL: http://data.bter.com/api2/1/marketlist

示例

    # Request
    GET: http://data.bter.com/api2/1/marketlist
    # Response
       {
        "result": "true",
        "data": [
                {
                    "no": 1,
                    "symbol": "LTC",
                    "name": "Litecoin",
                    "name_en": "Litecoin",
                    "name_cn": "莱特币",
                    "pair": "ltc_cny",
                    "rate": "418.00",
                    "vol_a": 168120.2,
                    "vol_b": "65,616,561",
                    "curr_a": "LTC",
                    "curr_b": "CNY",
                    "curr_suffix": " CNY",
                    "rate_percent": "19.73",
                    "trend": "up",
                    "supply": 25760300,
                    "marketcap": "10,767,805,404",
                    "plot": null
                },
                {
                    "no": 2,
                    "symbol": "DOC",
                    "name": "Dochain",
                    "name_en": "Dochain",
                    "name_cn": "域链",
                    "pair": "doc_cny",
                    "rate": "0.7450",
                    "vol_a": 65227328.3,
                    "vol_b": "51,041,999",
                    "curr_a": "DOC",
                    "curr_b": "CNY",
                    "curr_suffix": " CNY",
                    "rate_percent": "-1.84",
                    "trend": "up",
                    "supply": 1050000000,
                    "marketcap": "782,250,000",
                    "plot": null
                }
            ]
    }
            

返回值说明

    symbol : 币种标识
    name: 币种名称
    name_en: 英文名称
    name_cn: 中文名称
    pair: 交易对
    rate: 当前价格
    vol_a: 被兑换货币交易量
    vol_b: 兑换货币交易量
    curr_a: 被兑换货币
    curr_b: 兑换货币
    curr_suffix: 货币类型后缀
    rate_percent: 涨跌百分百
    trend: 24小时趋势 up涨 down跌
    supply: 币种供应量
    marketcap: 总市值
    plot: 趋势数据

4. 所有交易行情 API

返回系统支持的所有交易对的 最新,最高,最低 交易行情和交易量,每10秒钟更新:

URL: http://data.bter.com/api2/1/tickers

示例

    # Request
    GET: http://data.bter.com/api2/1/tickers
    # Response
      {
        "btc_cny": {
                "result": "true",
                "last": 28666,
                "lowestAsk": 28679.9,
                "highestBid": 28668,
                "percentChange": -1.0151933701657,
                "baseVolume": 17302843.8,
                "quoteVolume": 601.0685,
                "high24hr": 29000.8,
                "low24hr": 28521.2
            },
        "xrp_btc": {
                "result": "true",
                "last": "0.00004720",
                "lowestAsk": "0.00005620",
                "highestBid": "0.00004550",
                "percentChange": -7.4510907045863,
                "baseVolume": 0.5324,
                "quoteVolume": 11417.333,
                "high24hr": "0.00005580",
                "low24hr": "0.00004560"
            }
        }
            

返回值说明

    baseVolume: 交易量
    high24hr:24小时最高价
    highestBid:买方最高价
    last:最新成交价
    low24hr:24小时最低价
    lowestAsk:卖方最低价
    percentChange:涨跌百分比
    quoteVolume: 兑换货币交易量

5. 单项交易行情 API

返回最新,最高,最低 交易行情和交易量,每10秒钟更新:

URL: http://data.bter.com/api2/1/ticker/[CURR_A]_[CURR_B]

请替换 [CURR_A] and [CURR_B] 为您需要查看的币种.

支持的兑换类型:

  1. http://data.bter.com/api2/1/ticker/btc_cny
  2. http://data.bter.com/api2/1/ticker/ltc_cny
  3. http://data.bter.com/api2/1/ticker/xrp_cny
  4. http://data.bter.com/api2/1/ticker/xrp_btc
  5. http://data.bter.com/api2/1/ticker/bcc_cny
  6. http://data.bter.com/api2/1/ticker/bcc_btc
  7. http://data.bter.com/api2/1/ticker/qtum_btc
  8. http://data.bter.com/api2/1/ticker/qtum_eth
  9. http://data.bter.com/api2/1/ticker/qtum_cny
  10. http://data.bter.com/api2/1/ticker/zrx_btc
  11. http://data.bter.com/api2/1/ticker/zrx_eth
  12. http://data.bter.com/api2/1/ticker/zrx_cny
  13. http://data.bter.com/api2/1/ticker/dnt_btc
  14. http://data.bter.com/api2/1/ticker/dnt_eth
  15. http://data.bter.com/api2/1/ticker/dnt_cny
  16. http://data.bter.com/api2/1/ticker/llt_eth
  17. http://data.bter.com/api2/1/ticker/llt_cny
  18. http://data.bter.com/api2/1/ticker/dpy_eth
  19. http://data.bter.com/api2/1/ticker/etp_btc
  20. http://data.bter.com/api2/1/ticker/etp_cny
  21. http://data.bter.com/api2/1/ticker/oax_btc
  22. http://data.bter.com/api2/1/ticker/oax_eth
  23. http://data.bter.com/api2/1/ticker/ubc_btc
  24. http://data.bter.com/api2/1/ticker/ubc_eth
  25. http://data.bter.com/api2/1/ticker/lrc_eth
  26. http://data.bter.com/api2/1/ticker/lrc_cny
  27. http://data.bter.com/api2/1/ticker/pst_btc
  28. http://data.bter.com/api2/1/ticker/pst_eth
  29. http://data.bter.com/api2/1/ticker/pst_cny
  30. http://data.bter.com/api2/1/ticker/tnt_eth
  31. http://data.bter.com/api2/1/ticker/tnt_cny
  32. http://data.bter.com/api2/1/ticker/bts_cny
  33. http://data.bter.com/api2/1/ticker/cnc_cny
  34. http://data.bter.com/api2/1/ticker/rep_cny
  35. http://data.bter.com/api2/1/ticker/bat_cny
  36. http://data.bter.com/api2/1/ticker/snt_cny
  37. http://data.bter.com/api2/1/ticker/snt_btc
  38. http://data.bter.com/api2/1/ticker/snt_eth
  39. http://data.bter.com/api2/1/ticker/btm_eth
  40. http://data.bter.com/api2/1/ticker/omg_cny
  41. http://data.bter.com/api2/1/ticker/omg_btc
  42. http://data.bter.com/api2/1/ticker/omg_eth
  43. http://data.bter.com/api2/1/ticker/pay_cny
  44. http://data.bter.com/api2/1/ticker/pay_btc
  45. http://data.bter.com/api2/1/ticker/pay_eth
  46. http://data.bter.com/api2/1/ticker/bat_eth
  47. http://data.bter.com/api2/1/ticker/ico_cny
  48. http://data.bter.com/api2/1/ticker/ico_btc
  49. http://data.bter.com/api2/1/ticker/ico_eth
  50. http://data.bter.com/api2/1/ticker/cvc_cny
  51. http://data.bter.com/api2/1/ticker/cvc_btc
  52. http://data.bter.com/api2/1/ticker/cvc_eth
  53. http://data.bter.com/api2/1/ticker/doc_cny
  54. http://data.bter.com/api2/1/ticker/doc_btc
  55. http://data.bter.com/api2/1/ticker/storj_cny
  56. http://data.bter.com/api2/1/ticker/storj_btc
  57. http://data.bter.com/api2/1/ticker/storj_eth
  58. http://data.bter.com/api2/1/ticker/eos_cny
  59. http://data.bter.com/api2/1/ticker/eos_btc
  60. http://data.bter.com/api2/1/ticker/eos_eth
  61. http://data.bter.com/api2/1/ticker/doge_cny
  62. http://data.bter.com/api2/1/ticker/dash_cny
  63. http://data.bter.com/api2/1/ticker/eth_cny
  64. http://data.bter.com/api2/1/ticker/etc_cny
  65. http://data.bter.com/api2/1/ticker/exc_cny
  66. http://data.bter.com/api2/1/ticker/ftc_cny
  67. http://data.bter.com/api2/1/ticker/ifc_cny
  68. http://data.bter.com/api2/1/ticker/nmc_cny
  69. http://data.bter.com/api2/1/ticker/nxt_cny
  70. http://data.bter.com/api2/1/ticker/ppc_cny
  71. http://data.bter.com/api2/1/ticker/shell_cny
  72. http://data.bter.com/api2/1/ticker/tips_cny
  73. http://data.bter.com/api2/1/ticker/tix_cny
  74. http://data.bter.com/api2/1/ticker/xcp_cny
  75. http://data.bter.com/api2/1/ticker/xmr_cny
  76. http://data.bter.com/api2/1/ticker/xpm_cny
  77. http://data.bter.com/api2/1/ticker/xtc_cny
  78. http://data.bter.com/api2/1/ticker/ltc_btc
  79. http://data.bter.com/api2/1/ticker/bts_btc
  80. http://data.bter.com/api2/1/ticker/cnc_btc
  81. http://data.bter.com/api2/1/ticker/rep_btc
  82. http://data.bter.com/api2/1/ticker/bat_btc
  83. http://data.bter.com/api2/1/ticker/hkg_btc
  84. http://data.bter.com/api2/1/ticker/doge_btc
  85. http://data.bter.com/api2/1/ticker/dash_btc
  86. http://data.bter.com/api2/1/ticker/eth_btc
  87. http://data.bter.com/api2/1/ticker/etc_btc
  88. http://data.bter.com/api2/1/ticker/ftc_btc
  89. http://data.bter.com/api2/1/ticker/nmc_btc
  90. http://data.bter.com/api2/1/ticker/nxt_btc
  91. http://data.bter.com/api2/1/ticker/ppc_btc
  92. http://data.bter.com/api2/1/ticker/xtc_btc
  93. http://data.bter.com/api2/1/ticker/xcn_btc
  94. http://data.bter.com/api2/1/ticker/xcp_btc
  95. http://data.bter.com/api2/1/ticker/xem_btc
  96. http://data.bter.com/api2/1/ticker/xem_cny
  97. http://data.bter.com/api2/1/ticker/xpm_btc
  98. http://data.bter.com/api2/1/ticker/xmr_btc
  99. http://data.bter.com/api2/1/ticker/mg_btc
  100. http://data.bter.com/api2/1/ticker/ifc_ltc
  101. http://data.bter.com/api2/1/ticker/tips_ltc
  102. http://data.bter.com/api2/1/ticker/tix_ltc
  103. http://data.bter.com/api2/1/ticker/etc_eth
  104. http://data.bter.com/api2/1/ticker/zec_btc
  105. http://data.bter.com/api2/1/ticker/zec_cny

示例

    # Request
    GET: http://data.bter.com/api2/1/ticker/btc_cny
    # Response
      {
        "result": "true",
        "last": 28555,
        "lowestAsk": 28625,
        "highestBid": 28555,
        "percentChange": -0.97279360681029,
        "baseVolume": 17413127.85,
        "quoteVolume": 605.0491,
        "high24hr": 29000.8,
        "low24hr": 28500
      }
            

返回值说明

    baseVolume: 交易量
    high24hr:24小时最高价
    highestBid:买方最高价
    last:最新成交价
    low24hr:24小时最低价
    lowestAsk:卖方最低价
    percentChange:涨跌百分比
    quoteVolume: 兑换货币交易量

6. 市场深度 API

返回系统支持的所有交易对的市场深度(委托挂单),其中 asks 是委卖单, bids 是委买单。

URL: http://data.bter.com/api2/1/orderBooks


市场深度 API

返回当前市场深度(委托挂单),其中 asks 是委卖单, bids 是委买单。

URL: http://data.bter.com/api2/1/orderBook/[CURR_A]_[CURR_B]

请替换 [CURR_A] and [CURR_B] 为您需要查看的币种.

支持的兑换类型:

  1. http://data.bter.com/api2/1/orderBook/btc_cny
  2. http://data.bter.com/api2/1/orderBook/ltc_cny
  3. http://data.bter.com/api2/1/orderBook/xrp_cny
  4. http://data.bter.com/api2/1/orderBook/xrp_btc
  5. http://data.bter.com/api2/1/orderBook/bcc_cny
  6. http://data.bter.com/api2/1/orderBook/bcc_btc
  7. http://data.bter.com/api2/1/orderBook/qtum_btc
  8. http://data.bter.com/api2/1/orderBook/qtum_eth
  9. http://data.bter.com/api2/1/orderBook/qtum_cny
  10. http://data.bter.com/api2/1/orderBook/zrx_btc
  11. http://data.bter.com/api2/1/orderBook/zrx_eth
  12. http://data.bter.com/api2/1/orderBook/zrx_cny
  13. http://data.bter.com/api2/1/orderBook/dnt_btc
  14. http://data.bter.com/api2/1/orderBook/dnt_eth
  15. http://data.bter.com/api2/1/orderBook/dnt_cny
  16. http://data.bter.com/api2/1/orderBook/llt_eth
  17. http://data.bter.com/api2/1/orderBook/llt_cny
  18. http://data.bter.com/api2/1/orderBook/dpy_eth
  19. http://data.bter.com/api2/1/orderBook/etp_btc
  20. http://data.bter.com/api2/1/orderBook/etp_cny
  21. http://data.bter.com/api2/1/orderBook/oax_btc
  22. http://data.bter.com/api2/1/orderBook/oax_eth
  23. http://data.bter.com/api2/1/orderBook/ubc_btc
  24. http://data.bter.com/api2/1/orderBook/ubc_eth
  25. http://data.bter.com/api2/1/orderBook/lrc_eth
  26. http://data.bter.com/api2/1/orderBook/lrc_cny
  27. http://data.bter.com/api2/1/orderBook/pst_btc
  28. http://data.bter.com/api2/1/orderBook/pst_eth
  29. http://data.bter.com/api2/1/orderBook/pst_cny
  30. http://data.bter.com/api2/1/orderBook/tnt_eth
  31. http://data.bter.com/api2/1/orderBook/tnt_cny
  32. http://data.bter.com/api2/1/orderBook/bts_cny
  33. http://data.bter.com/api2/1/orderBook/cnc_cny
  34. http://data.bter.com/api2/1/orderBook/rep_cny
  35. http://data.bter.com/api2/1/orderBook/bat_cny
  36. http://data.bter.com/api2/1/orderBook/snt_cny
  37. http://data.bter.com/api2/1/orderBook/snt_btc
  38. http://data.bter.com/api2/1/orderBook/snt_eth
  39. http://data.bter.com/api2/1/orderBook/btm_eth
  40. http://data.bter.com/api2/1/orderBook/omg_cny
  41. http://data.bter.com/api2/1/orderBook/omg_btc
  42. http://data.bter.com/api2/1/orderBook/omg_eth
  43. http://data.bter.com/api2/1/orderBook/pay_cny
  44. http://data.bter.com/api2/1/orderBook/pay_btc
  45. http://data.bter.com/api2/1/orderBook/pay_eth
  46. http://data.bter.com/api2/1/orderBook/bat_eth
  47. http://data.bter.com/api2/1/orderBook/ico_cny
  48. http://data.bter.com/api2/1/orderBook/ico_btc
  49. http://data.bter.com/api2/1/orderBook/ico_eth
  50. http://data.bter.com/api2/1/orderBook/cvc_cny
  51. http://data.bter.com/api2/1/orderBook/cvc_btc
  52. http://data.bter.com/api2/1/orderBook/cvc_eth
  53. http://data.bter.com/api2/1/orderBook/doc_cny
  54. http://data.bter.com/api2/1/orderBook/doc_btc
  55. http://data.bter.com/api2/1/orderBook/storj_cny
  56. http://data.bter.com/api2/1/orderBook/storj_btc
  57. http://data.bter.com/api2/1/orderBook/storj_eth
  58. http://data.bter.com/api2/1/orderBook/eos_cny
  59. http://data.bter.com/api2/1/orderBook/eos_btc
  60. http://data.bter.com/api2/1/orderBook/eos_eth
  61. http://data.bter.com/api2/1/orderBook/doge_cny
  62. http://data.bter.com/api2/1/orderBook/dash_cny
  63. http://data.bter.com/api2/1/orderBook/eth_cny
  64. http://data.bter.com/api2/1/orderBook/etc_cny
  65. http://data.bter.com/api2/1/orderBook/exc_cny
  66. http://data.bter.com/api2/1/orderBook/ftc_cny
  67. http://data.bter.com/api2/1/orderBook/ifc_cny
  68. http://data.bter.com/api2/1/orderBook/nmc_cny
  69. http://data.bter.com/api2/1/orderBook/nxt_cny
  70. http://data.bter.com/api2/1/orderBook/ppc_cny
  71. http://data.bter.com/api2/1/orderBook/shell_cny
  72. http://data.bter.com/api2/1/orderBook/tips_cny
  73. http://data.bter.com/api2/1/orderBook/tix_cny
  74. http://data.bter.com/api2/1/orderBook/xcp_cny
  75. http://data.bter.com/api2/1/orderBook/xmr_cny
  76. http://data.bter.com/api2/1/orderBook/xpm_cny
  77. http://data.bter.com/api2/1/orderBook/xtc_cny
  78. http://data.bter.com/api2/1/orderBook/ltc_btc
  79. http://data.bter.com/api2/1/orderBook/bts_btc
  80. http://data.bter.com/api2/1/orderBook/cnc_btc
  81. http://data.bter.com/api2/1/orderBook/rep_btc
  82. http://data.bter.com/api2/1/orderBook/bat_btc
  83. http://data.bter.com/api2/1/orderBook/hkg_btc
  84. http://data.bter.com/api2/1/orderBook/doge_btc
  85. http://data.bter.com/api2/1/orderBook/dash_btc
  86. http://data.bter.com/api2/1/orderBook/eth_btc
  87. http://data.bter.com/api2/1/orderBook/etc_btc
  88. http://data.bter.com/api2/1/orderBook/ftc_btc
  89. http://data.bter.com/api2/1/orderBook/nmc_btc
  90. http://data.bter.com/api2/1/orderBook/nxt_btc
  91. http://data.bter.com/api2/1/orderBook/ppc_btc
  92. http://data.bter.com/api2/1/orderBook/xtc_btc
  93. http://data.bter.com/api2/1/orderBook/xcn_btc
  94. http://data.bter.com/api2/1/orderBook/xcp_btc
  95. http://data.bter.com/api2/1/orderBook/xem_btc
  96. http://data.bter.com/api2/1/orderBook/xem_cny
  97. http://data.bter.com/api2/1/orderBook/xpm_btc
  98. http://data.bter.com/api2/1/orderBook/xmr_btc
  99. http://data.bter.com/api2/1/orderBook/mg_btc
  100. http://data.bter.com/api2/1/orderBook/ifc_ltc
  101. http://data.bter.com/api2/1/orderBook/tips_ltc
  102. http://data.bter.com/api2/1/orderBook/tix_ltc
  103. http://data.bter.com/api2/1/orderBook/etc_eth
  104. http://data.bter.com/api2/1/orderBook/zec_btc
  105. http://data.bter.com/api2/1/orderBook/zec_cny

示例

    # Request
    GET: http://data.bter.com/api2/1/orderBook/btc_cny
    # Response
      {
        "result": "true",
        "asks": [
                [29500,    4.07172355],
                [29499,    0.00203397],
                [29495,    1],
                [29488,    0.0672],
                [29475,    0.001]
            ],
        "bids": [
                [28001, 0.0477],
                [28000, 0.35714018],
                [28000, 2.56222976],
                [27800, 0.0015],
                [27777, 0.1]
            ]
        }
            

返回值说明

    asks :卖方深度
    bids :买方深度

7. 历史成交记录 API

返回最新80条历史成交记录:

URL: http://data.bter.com/api2/1/tradeHistory/[CURR_A]_[CURR_B]

示例

    # Request
    GET: http://data.bter.com/api2/1/tradeHistory/btc_cny
    # Response
    {
        "result": "true",
        "elapsed": "2.629ms",
        "data": [
                {
                "tradeID": "3275574",
                "date": "2017-08-28 01:49:06",
                "type": "buy",
                "rate": 28200,
                "amount": 0.3204,
                "total": 9035.28
                },
                {
                "tradeID": "3275575",
                "date": "2017-08-28 01:49:07",
                "type": "sell",
                "rate": 28100,
                "amount": 0.0388,
                "total": 1090.28
                }
            ]
        }
            

返回从[TID]往后的最多1000历史成交记录:

URL: http://data.bter.com/api2/1/tradeHistory/[CURR_A]_[CURR_B]/[TID]

请替换 [CURR_A] and [CURR_B] 为您需要查看的币种.

支持的兑换类型:

  1. http://data.bter.com/api2/1/tradeHistory/btc_cny
  2. http://data.bter.com/api2/1/tradeHistory/ltc_cny
  3. http://data.bter.com/api2/1/tradeHistory/xrp_cny
  4. http://data.bter.com/api2/1/tradeHistory/xrp_btc
  5. http://data.bter.com/api2/1/tradeHistory/bcc_cny
  6. http://data.bter.com/api2/1/tradeHistory/bcc_btc
  7. http://data.bter.com/api2/1/tradeHistory/qtum_btc
  8. http://data.bter.com/api2/1/tradeHistory/qtum_eth
  9. http://data.bter.com/api2/1/tradeHistory/qtum_cny
  10. http://data.bter.com/api2/1/tradeHistory/zrx_btc
  11. http://data.bter.com/api2/1/tradeHistory/zrx_eth
  12. http://data.bter.com/api2/1/tradeHistory/zrx_cny
  13. http://data.bter.com/api2/1/tradeHistory/dnt_btc
  14. http://data.bter.com/api2/1/tradeHistory/dnt_eth
  15. http://data.bter.com/api2/1/tradeHistory/dnt_cny
  16. http://data.bter.com/api2/1/tradeHistory/llt_eth
  17. http://data.bter.com/api2/1/tradeHistory/llt_cny
  18. http://data.bter.com/api2/1/tradeHistory/dpy_eth
  19. http://data.bter.com/api2/1/tradeHistory/etp_btc
  20. http://data.bter.com/api2/1/tradeHistory/etp_cny
  21. http://data.bter.com/api2/1/tradeHistory/oax_btc
  22. http://data.bter.com/api2/1/tradeHistory/oax_eth
  23. http://data.bter.com/api2/1/tradeHistory/ubc_btc
  24. http://data.bter.com/api2/1/tradeHistory/ubc_eth
  25. http://data.bter.com/api2/1/tradeHistory/lrc_eth
  26. http://data.bter.com/api2/1/tradeHistory/lrc_cny
  27. http://data.bter.com/api2/1/tradeHistory/pst_btc
  28. http://data.bter.com/api2/1/tradeHistory/pst_eth
  29. http://data.bter.com/api2/1/tradeHistory/pst_cny
  30. http://data.bter.com/api2/1/tradeHistory/tnt_eth
  31. http://data.bter.com/api2/1/tradeHistory/tnt_cny
  32. http://data.bter.com/api2/1/tradeHistory/bts_cny
  33. http://data.bter.com/api2/1/tradeHistory/cnc_cny
  34. http://data.bter.com/api2/1/tradeHistory/rep_cny
  35. http://data.bter.com/api2/1/tradeHistory/bat_cny
  36. http://data.bter.com/api2/1/tradeHistory/snt_cny
  37. http://data.bter.com/api2/1/tradeHistory/snt_btc
  38. http://data.bter.com/api2/1/tradeHistory/snt_eth
  39. http://data.bter.com/api2/1/tradeHistory/btm_eth
  40. http://data.bter.com/api2/1/tradeHistory/omg_cny
  41. http://data.bter.com/api2/1/tradeHistory/omg_btc
  42. http://data.bter.com/api2/1/tradeHistory/omg_eth
  43. http://data.bter.com/api2/1/tradeHistory/pay_cny
  44. http://data.bter.com/api2/1/tradeHistory/pay_btc
  45. http://data.bter.com/api2/1/tradeHistory/pay_eth
  46. http://data.bter.com/api2/1/tradeHistory/bat_eth
  47. http://data.bter.com/api2/1/tradeHistory/ico_cny
  48. http://data.bter.com/api2/1/tradeHistory/ico_btc
  49. http://data.bter.com/api2/1/tradeHistory/ico_eth
  50. http://data.bter.com/api2/1/tradeHistory/cvc_cny
  51. http://data.bter.com/api2/1/tradeHistory/cvc_btc
  52. http://data.bter.com/api2/1/tradeHistory/cvc_eth
  53. http://data.bter.com/api2/1/tradeHistory/doc_cny
  54. http://data.bter.com/api2/1/tradeHistory/doc_btc
  55. http://data.bter.com/api2/1/tradeHistory/storj_cny
  56. http://data.bter.com/api2/1/tradeHistory/storj_btc
  57. http://data.bter.com/api2/1/tradeHistory/storj_eth
  58. http://data.bter.com/api2/1/tradeHistory/eos_cny
  59. http://data.bter.com/api2/1/tradeHistory/eos_btc
  60. http://data.bter.com/api2/1/tradeHistory/eos_eth
  61. http://data.bter.com/api2/1/tradeHistory/doge_cny
  62. http://data.bter.com/api2/1/tradeHistory/dash_cny
  63. http://data.bter.com/api2/1/tradeHistory/eth_cny
  64. http://data.bter.com/api2/1/tradeHistory/etc_cny
  65. http://data.bter.com/api2/1/tradeHistory/exc_cny
  66. http://data.bter.com/api2/1/tradeHistory/ftc_cny
  67. http://data.bter.com/api2/1/tradeHistory/ifc_cny
  68. http://data.bter.com/api2/1/tradeHistory/nmc_cny
  69. http://data.bter.com/api2/1/tradeHistory/nxt_cny
  70. http://data.bter.com/api2/1/tradeHistory/ppc_cny
  71. http://data.bter.com/api2/1/tradeHistory/shell_cny
  72. http://data.bter.com/api2/1/tradeHistory/tips_cny
  73. http://data.bter.com/api2/1/tradeHistory/tix_cny
  74. http://data.bter.com/api2/1/tradeHistory/xcp_cny
  75. http://data.bter.com/api2/1/tradeHistory/xmr_cny
  76. http://data.bter.com/api2/1/tradeHistory/xpm_cny
  77. http://data.bter.com/api2/1/tradeHistory/xtc_cny
  78. http://data.bter.com/api2/1/tradeHistory/ltc_btc
  79. http://data.bter.com/api2/1/tradeHistory/bts_btc
  80. http://data.bter.com/api2/1/tradeHistory/cnc_btc
  81. http://data.bter.com/api2/1/tradeHistory/rep_btc
  82. http://data.bter.com/api2/1/tradeHistory/bat_btc
  83. http://data.bter.com/api2/1/tradeHistory/hkg_btc
  84. http://data.bter.com/api2/1/tradeHistory/doge_btc
  85. http://data.bter.com/api2/1/tradeHistory/dash_btc
  86. http://data.bter.com/api2/1/tradeHistory/eth_btc
  87. http://data.bter.com/api2/1/tradeHistory/etc_btc
  88. http://data.bter.com/api2/1/tradeHistory/ftc_btc
  89. http://data.bter.com/api2/1/tradeHistory/nmc_btc
  90. http://data.bter.com/api2/1/tradeHistory/nxt_btc
  91. http://data.bter.com/api2/1/tradeHistory/ppc_btc
  92. http://data.bter.com/api2/1/tradeHistory/xtc_btc
  93. http://data.bter.com/api2/1/tradeHistory/xcn_btc
  94. http://data.bter.com/api2/1/tradeHistory/xcp_btc
  95. http://data.bter.com/api2/1/tradeHistory/xem_btc
  96. http://data.bter.com/api2/1/tradeHistory/xem_cny
  97. http://data.bter.com/api2/1/tradeHistory/xpm_btc
  98. http://data.bter.com/api2/1/tradeHistory/xmr_btc
  99. http://data.bter.com/api2/1/tradeHistory/mg_btc
  100. http://data.bter.com/api2/1/tradeHistory/ifc_ltc
  101. http://data.bter.com/api2/1/tradeHistory/tips_ltc
  102. http://data.bter.com/api2/1/tradeHistory/tix_ltc
  103. http://data.bter.com/api2/1/tradeHistory/etc_eth
  104. http://data.bter.com/api2/1/tradeHistory/zec_btc
  105. http://data.bter.com/api2/1/tradeHistory/zec_cny

示例

    # Request
    GET: http://data.bter.com/api2/1/tradeHistory/btc_cny/3275876
    # Response
    {
        "result": "true",
        "data": [
                {
                "tradeID": 3175762,
                "date": "2017-08-25 07:24:28",
                "type": "sell",
                "rate": 29011,
                "amount": 0.0019,
                "total": 55.1209
                },
                {
                "tradeID": 3175771,
                "date": "2017-08-25 07:24:41",
                "type": "sell",
                "rate": 29011,
                "amount": 0.0032,
                "total": 92.8352
                }
            ],
        "elapsed": "31.518ms"
    }
            

返回值说明

    amount: 成交币种数量
    date: 订单时间
    rate: 币种单价
    total: 订单总额
    tradeID: tradeID
    type: 买卖类型, buy买 sell卖

8. 自动交易 API

通过以下API,用户可以使用程序控制自动进行账号资金查询,下单交易,取消挂单。
请注意:请在您的程序中设置的HTTP请求头参数 Content-Type 为 application/x-www-form-urlencoded

用户首先要通过这个链接获取API接口身份认证用到的Key和Secret。 然后在程序中用Secret作为密码,通过SHA512加密方式签名需要POST给服务器的数据得到Sign,并在HTTPS请求的Header部分传回Key和Sign。请参考以下接口说明和例子程序进行设置。

获取帐号资金余额API

API URL: https://api.bter.com/api2/1/private/balances

参数数据提交方式:POST

参数:无

返回数据格式:JSON

示例

    # Request
    POST: https://api.bter.com/api2/1/private/balances
    # Response
    {
        "result": "true",
        "available": {
            "BTC": "1000",
            "ETH": "968.8",
            "ETC": "0",
            "CNY": "556249.69",
            "ICO": "102"
            },
        "locked": {
            "CNY": "4744.3257",
            "ETH": "1"
            }
    }
            

返回值说明

    available: 可用各币种资金余额
    locked : 冻结币种金额

获取充值地址API

API URL: https://api.bter.com/api2/1/private/depositeAddress

参数数据提交方式:POST

返回数据格式:JSON

请求参数

参数名 参数类型 必填 描述
currency String 币种 如(BTC, LTC)

示例

    # Request
    POST: https://api.bter.com/api2/1/private/depositeAddress
    # Response
    {
        "result": "true",
        "addr": "LPXtk1kWHioP62SzfqwKbYE3Z7Wt2ujYEc",
        "message": "Sucess",
        "code": 0
    }
            

返回值说明

    addr: 钱包地址

获取充值提现历史API

API URL: https://api.bter.com/api2/1/private/depositsWithdrawals

参数数据提交方式:POST

返回数据格式:JSON

请求参数

参数名 参数类型 必填 描述
start String 起始UNIX时间(如 1469092370)
end String 终止UNIX时间(如 1469713981)

示例

    # Request
    POST: https://api.bter.com/api2/1/private/depositsWithdrawals
    # Response
    {
        "result": "true",
        "deposits": [
                {
                "id": "c204730",
                "currency": "CNY",
                "address": "1111 1111 1111 1111 1111 1",
                "amount": "222.61",
                "txid": "210496",
                "timestamp": "1474962729",
                "status": "DONE"
                }

            ],
        "withdraws": [
                {
                "currency": "BTS",
                "address": "addr2",
                "amount": "600000000",
                "txid": "afsad33eda911f62d4eb88fasd7fd89af7d9fs32",
                "timestamp": "1469092378",
                "status": "DONE"
                }
            ],
        "message": "Success"
    }
            

返回值说明

    deposits: 充值
    withdraws: 提现
    currency: 币种
    address: 充值/提现地址
    amount: 金额
    timestamp: 发起时间戳
    status: 记录状态 DONE:完成; CANCEL:取消; REQUEST:请求中 

下单交易买入API

API URL: https://api.bter.com/api2/1/private/buy

参数数据提交方式:POST

返回数据格式:JSON

请求参数

参数名 参数类型 必填 描述
currencyPair String 交易币种对(如ltc_btc,ltc_btc)
rate String 价格
amount String 交易量

示例

    # Request
    POST: https://api.bter.com/api2/1/private/buy
    # Response
    {
        "result":"true",
        "orderNumber":"123456",
        "message":"Success"
    }

返回值说明

    orderNumber: 订单单号

注:返回的orderNumber可用于查询,取消订单。


下单交易卖出API

API URL: https://api.bter.com/api2/1/private/sell

参数数据提交方式:POST

返回数据格式:JSON

请求参数

参数名 参数类型 必填 描述
pair String 交易币种对(如ltc_btc,ltc_btc)
rate String 价格
amount String 交易量

示例

    # Request
    POST: https://api.bter.com/api2/1/private/sell
    # Response
    {
        "result":"true",
        "orderNumber":"123456",
        "message":"Success"
    }

返回值说明

    orderNumber: 订单单号

注:返回的orderNumber可用于查询,取消订单。


取消下单API

API URL: https://api.bter.com/api2/1/private/cancelOrder

参数数据提交方式:POST

返回数据格式:JSON

请求参数

参数名 参数类型 必填 描述
orderNumber String 下单单号
currencyPair String 交易币种对(如 ltc_btc)

示例

    # Request
    POST: https://api.bter.com/api2/1/private/cancelOrder
    # Response
   {"result":"true","message":"Success"}

返回值说明

    result: 是否成功 true成功 false失败
    message: 提示消息

取消多个下单API

API URL: https://api.bter.com/api2/1/private/cancelOrders

参数数据提交方式:POST

返回数据格式:JSON

请求参数

参数名 参数类型 必填 描述
orders_json String 下单单号和pair的json数据; 示例:[ { "orderNumber":"7942422" "currencyPair":"ltc_btc" }, { "orderNumber":"7942422" "currencyPair":"ltc_btc" } ]

示例

    # Request
    POST: https://api.bter.com/api2/1/private/cancelOrders
    # Response
   {"result":"true","message":"Success"}

返回值说明

    result: 是否成功 true成功 false失败
    message: 提示消息

取消所有下单API

API URL: https://api.bter.com/api2/1/private/cancelAllOrders

参数数据提交方式:POST

返回数据格式:JSON

请求参数

参数名 参数类型 必填 描述
type int 下单类型(0:卖出,1:买入,-1:不限制)
currencyPair String 交易币种对 (示例:ltc_btc)

示例

    # Request
    POST: https://api.bter.com/api2/1/private/cancelOrders
    # Response
   {"result":"true","message":"Success"}

返回值说明

    result: 是否成功 true成功 false失败
    message: 提示消息

获取下单状态API

API URL: https://api.bter.com/api2/1/private/getOrder

参数数据提交方式:POST

返回数据格式:JSON

请求参数

参数名 参数类型 必填 描述
orderNumber String 下单单号
currencyPair String 交易币种对(如:btc_cny)

示例

    # Request
    POST: https://api.bter.com/api2/1/private/getOrder
    # Response
    {
        "result":"true",
        "order":{
            "id":"15088",
            "status":"cancelled",
            "currencyPair":"btc_cny",
            "type":"sell",
            "rate":811,
            "amount":"0.39901357",
            "initialRate":811,
            "initialAmount":"1"
            },
        "message":"Success"
    }

返回值说明

    status: 订单状态 cancelled已取消 done已完成
    currencyPair: 交易对
    type: 买卖类型 sell卖出, buy买入
    rate: 价格
    amount: 买卖数量
    initialRate:下单价格
    initialAmount:下单量
                

获取我的当前挂单列表API

API URL: https://api.bter.com/api2/1/private/openOrders

参数数据提交方式:POST

参数:无

返回数据格式:JSON

示例

    # Request
    POST: https://api.bter.com/api2/1/private/openOrders
    # Response
    {
        "result": "true", "message": "Success", "code": 0,"elapsed": "6.262ms",
        "orders": [
                {
                "orderNumber": "30032151",
                "type": "buy",
                "rate": 21367.521367521,
                "amount": "0.0936",
                "total": "2000",
                "initialRate": 21367.521367521,
                "initialAmount": "0.0936",
                "filledRate": 0,
                "filledAmount": 0,
                "currencyPair": "doge_cny",
                "timestamp": "1407828913",
                "status": "open"
                }
            ]
        }

返回值说明

    amount: 订单总数量 剩余未成交数量
    currencyPair: 订单交易对
    filledAmount: 已成交量
    filledRate: 成交价格
    initialAmount: 下单量
    initialRate: 下单价格
    orderNumber: 订单号
    rate: 交易单价
    status: 订单状态
    timestamp: 时间戳
    total:总计
    type: 买卖类型 buy:买入;sell:卖出

获取我的24小时内成交记录API

API URL: https://api.bter.com/api2/1/private/tradeHistory

参数数据提交方式:POST

返回数据格式:JSON

参数:

参数名 参数类型 必填 描述
currencyPair String 交易币种对
orderNumber String 订单号

示例

    # Request
    POST: https://api.bter.com/api2/1/private/tradeHistory
    # Response
    {
        "result": "true",
        "message": "Success",
        "trades": [
                {
                "id": "7942422",
                "orderid": "38100491",
                "pair": "ltc_btc",
                "type": "buy",
                "rate": "0.01719",
                "amount": "0.0588",
                "time": "06-12 02:49:11",
                "time_unix": "1402512551"
                }
            ]
    }

返回值说明

    orderid: 订单id
    pair: 交易对
    type: 买卖类型
    rate: 买卖价格
    amount: 订单买卖币种数量
    time: 订单时间
    time_unix: 订单unix时间戳

提现API

API URL: https://api.bter.com/api2/1/private/withdraw

参数数据提交方式:POST

返回数据格式:JSON

请求参数

参数名 参数类型 必填 描述
currency String 提现币种(如:btc)
amount String 提现数量
address String 提现地址(如:1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs)

示例

    # Request
    POST: https://api.bter.com/api2/1/private/withdraw
    # Response
    { "result": "true",  "message": "Success"}

返回值说明

    result: 是否成功 true成功 false失败
    message: 提示消息

9. 错误代码说明

系统返回错误码对应说明

错误代码 详细描述
1 无效请求
2 无效版本
3 无效请求
4 请求太频繁,稍后再试
5,6 Key或签名无效,请重新创建
7 币种对不支持
8,9 币种不支持
10 验证错误
11 地址获取失败
12 参数为空
13 系统错误,联系管理员
14 无效用户
15 撤单太频繁,一分钟后再试
16 无效单号,或挂单已撤销
17 无效单号
18 无效挂单量
19 交易已暂停
20 挂单量太小
21 资金不足

PHP示例程序

				

<?php

	function bter_query($path, array $req = array()) {
		// API settings, add your Key and Secret at here
		$key = '';
		$secret = '';
	 
		// generate a nonce to avoid problems with 32bits systems
		$mt = explode(' ', microtime());
		$req['nonce'] = $mt[1].substr($mt[0], 2, 6);
	 
		// generate the POST data string
		$post_data = http_build_query($req, '', '&');
		$sign = hash_hmac('sha512', $post_data, $secret);
	 
		// generate the extra headers
		$headers = array(
			'KEY: '.$key,
			'SIGN: '.$sign
		);

		//!!! please set Content-Type to application/x-www-form-urlencoded if it's not the default value

		// curl handle (initialize if required)
		static $ch = null;
		if (is_null($ch)) {
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Bter PHP bot; '.php_uname('a').'; PHP/'.phpversion().')');
		}
		
		curl_setopt($ch, CURLOPT_URL, 'https://api.bter.com/api2/'.$path);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);


		// run the query
		$res = curl_exec($ch);
		
		if ($res === false) throw new Exception('Could not get reply: '.curl_error($ch));
		//var_dump($res);
		//print_r($res);
		$dec = json_decode($res, true);
		if (!$dec) throw new Exception('Invalid data received, please make sure connection is working and requested API exists: '.$res);

		return $dec;
	}
 
	
	function curl_file_get_contents($url) {
		
		// our curl handle (initialize if required)
		static $ch = null;
		if (is_null($ch)) {
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($ch, CURLOPT_USERAGENT, 
				'Mozilla/4.0 (compatible; Bter PHP bot; '.php_uname('a').'; PHP/'.phpversion().')'
				);
		}
		curl_setopt($ch, CURLOPT_URL, 'https://api.bter.com/api2/'.$url);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

		// run the query
		$res = curl_exec($ch);
		if ($res === false) throw new Exception('Could not get reply: '.curl_error($ch));
		//echo $res;
		$dec = json_decode($res, true);
		if (!$dec) throw new Exception('Invalid data: '.$res);
		
		return $dec;
	}

	function get_top_rate($currency_pair, $type='BUY') {
		
		$url = '1/orderBook/'.strtoupper($currency_pair);
		$json = curl_file_get_contents($url);
		
		$rate = 0;

		if (strtoupper($type) == 'BUY') {
			$r =  $json['bids'][0];
			$rate = $r[0];
		} else  {
			$r = end($json['asks']);
			$rate = $r[0];
		}

		return $rate;
	}	
	
	function get_pairs() {
		
		$url = '1/pairs';
		$json = curl_file_get_contents($url);
		
		return $json;		
	}
	
	function get_marketinfo(){
		
		$url = '1/marketinfo';
		$json = curl_file_get_contents($url);
		
		return $json;		
	}
	 
	function get_tickers(){
		
		$url = '1/tickers';
		$json = curl_file_get_contents($url);
		
		return $json;		
	}
	 
	function get_ticker($current_pairs){
		
		$url = '1/ticker/'.strtoupper($current_pairs);
		$json = curl_file_get_contents($url);
		
		return $json;		
	}
	 
	function get_orderbooks(){
		
		$url = '1/orderBooks';
		$json = curl_file_get_contents($url);
		
		return $json;
	}
	 
	function get_orderbook($current_pairs){
		
		$url = '1/orderBooks/'.strtoupper($current_pairs);
		$json = curl_file_get_contents($url);
		
		return $json;
	}
	 
	function get_trade_history($current_pairs, $tid){
		
		$url = '1/tradeHistory/'.strtoupper($current_pairs).'/'.$tid;
		$json = curl_file_get_contents($url);
		
		return $json;
	}	
	
	function get_balances() {
		
		return bter_query('1/private/balances');		
	}
	
	function get_order_trades($order_number) {
		
		return bter_query('1/private/orderTrades',
			array(
				'orderNumber' => $order_number
			)
		);
	}
	
	function withdraw($currency, $amount, $address) {
		
		return bter_query('1/private/withdraw',
			array(
				'currency' => strtoupper($currency),
				'amount' => $amount,
				'address' => $address
			)
		);
	}
	
	function get_order($order_number) {
		
		return bter_query('1/private/getOrder', 
			array(
				'orderNumber' => $order_number
			)
		);
	}
	
	function cancel_order($order_number) {
		
		return bter_query('1/private/cancelOrder',
			array(
				'orderNumber' => $order_number
			)
		);
	}
	
	function cancel_all_orders($type, $currency_pair) {
		
		return bter_query('1/private/cancelAllOrders',
			array(
				'type' => $type,
				'currencyPair' => strtoupper($currency_pair)
			)
		);
	}
	
	function sell($currency_pair, $rate, $amount) {
		
		return bter_query('1/private/sell',
			array(
				'currencyPair' => strtoupper($currency_pair),
				'rate' => $rate,
				'amount' => $amount,
			)
		);
	}
	
	function buy($currency_pair, $rate, $amount) {
		
		return bter_query('1/private/buy',
			array(
				'currencyPair' => strtoupper($currency_pair),
				'rate' => $rate,
				'amount' => $amount,
			)
		);
	}
	
	function get_my_trade_history($currency_pair, $order_number) {
		
		return bter_query('1/private/tradeHistory',
			array(
				'currencyPair' => strtoupper($currency_pair),
				'orderNumber' => $order_number
			)
		);
	}
	
	function open_orders() {
		
		return bter_query('1/private/openOrders');
	}
	
	function deposit_address($currency) {
		
		return bter_query('1/private/depositAddress',
			array(
				'currency' => strtoupper($currency)
			)
		);
	}


	try {
		// example 1: get balances
		var_dump(get_balances());
		
		// example 2: place a buy order
		$pair = 'ltc_btc';
		$rate = get_top_rate($pair, $type) * 1.01;
		var_dump(buy($pair, $rate, '0.01'));
		
		// example 3: cancel an order
		var_dump(cancel_order(125811));
		
		// example 4: get order status
		var_dump(get_order(15088));
		
		// example 5: list all open orders
		var_dump(open_orders());

	} catch (Exception $e) {
		echo "Error:".$e->getMessage();
		
	} 
?>