• BTC : ¥28307.57
  • LTC : ¥307.36
  • ETH : ¥2027.96
  • ETC : ¥93.21
  • QTUM : ¥74.40

比特儿API 2.0

1. 所有交易对 API

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

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


2. 交易市场订单参数 API

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

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


3. 交易市场详细行情 API

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

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


4. 所有交易行情 API

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

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


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/etp_btc
  11. http://data.bter.com/api2/1/ticker/etp_cny
  12. http://data.bter.com/api2/1/ticker/btrx_cny
  13. http://data.bter.com/api2/1/ticker/btrx_btc
  14. http://data.bter.com/api2/1/ticker/bts_cny
  15. http://data.bter.com/api2/1/ticker/cnc_cny
  16. http://data.bter.com/api2/1/ticker/rep_cny
  17. http://data.bter.com/api2/1/ticker/bat_cny
  18. http://data.bter.com/api2/1/ticker/snt_cny
  19. http://data.bter.com/api2/1/ticker/snt_btc
  20. http://data.bter.com/api2/1/ticker/snt_eth
  21. http://data.bter.com/api2/1/ticker/btm_cny
  22. http://data.bter.com/api2/1/ticker/btm_btc
  23. http://data.bter.com/api2/1/ticker/omg_cny
  24. http://data.bter.com/api2/1/ticker/omg_btc
  25. http://data.bter.com/api2/1/ticker/omg_eth
  26. http://data.bter.com/api2/1/ticker/pay_cny
  27. http://data.bter.com/api2/1/ticker/pay_btc
  28. http://data.bter.com/api2/1/ticker/pay_eth
  29. http://data.bter.com/api2/1/ticker/bat_eth
  30. http://data.bter.com/api2/1/ticker/ico_cny
  31. http://data.bter.com/api2/1/ticker/ico_btc
  32. http://data.bter.com/api2/1/ticker/ico_eth
  33. http://data.bter.com/api2/1/ticker/cvc_cny
  34. http://data.bter.com/api2/1/ticker/cvc_btc
  35. http://data.bter.com/api2/1/ticker/cvc_eth
  36. http://data.bter.com/api2/1/ticker/ven_cny
  37. http://data.bter.com/api2/1/ticker/ven_btc
  38. http://data.bter.com/api2/1/ticker/storj_cny
  39. http://data.bter.com/api2/1/ticker/storj_btc
  40. http://data.bter.com/api2/1/ticker/storj_eth
  41. http://data.bter.com/api2/1/ticker/eos_cny
  42. http://data.bter.com/api2/1/ticker/eos_btc
  43. http://data.bter.com/api2/1/ticker/eos_eth
  44. http://data.bter.com/api2/1/ticker/doge_cny
  45. http://data.bter.com/api2/1/ticker/dash_cny
  46. http://data.bter.com/api2/1/ticker/eth_cny
  47. http://data.bter.com/api2/1/ticker/etc_cny
  48. http://data.bter.com/api2/1/ticker/exc_cny
  49. http://data.bter.com/api2/1/ticker/ftc_cny
  50. http://data.bter.com/api2/1/ticker/ifc_cny
  51. http://data.bter.com/api2/1/ticker/nmc_cny
  52. http://data.bter.com/api2/1/ticker/nxt_cny
  53. http://data.bter.com/api2/1/ticker/ppc_cny
  54. http://data.bter.com/api2/1/ticker/shell_cny
  55. http://data.bter.com/api2/1/ticker/tips_cny
  56. http://data.bter.com/api2/1/ticker/tix_cny
  57. http://data.bter.com/api2/1/ticker/xcp_cny
  58. http://data.bter.com/api2/1/ticker/xmr_cny
  59. http://data.bter.com/api2/1/ticker/xpm_cny
  60. http://data.bter.com/api2/1/ticker/xtc_cny
  61. http://data.bter.com/api2/1/ticker/ltc_btc
  62. http://data.bter.com/api2/1/ticker/bts_btc
  63. http://data.bter.com/api2/1/ticker/cnc_btc
  64. http://data.bter.com/api2/1/ticker/rep_btc
  65. http://data.bter.com/api2/1/ticker/bat_btc
  66. http://data.bter.com/api2/1/ticker/hkg_btc
  67. http://data.bter.com/api2/1/ticker/doge_btc
  68. http://data.bter.com/api2/1/ticker/dash_btc
  69. http://data.bter.com/api2/1/ticker/eth_btc
  70. http://data.bter.com/api2/1/ticker/etc_btc
  71. http://data.bter.com/api2/1/ticker/ftc_btc
  72. http://data.bter.com/api2/1/ticker/nmc_btc
  73. http://data.bter.com/api2/1/ticker/nxt_btc
  74. http://data.bter.com/api2/1/ticker/ppc_btc
  75. http://data.bter.com/api2/1/ticker/xtc_btc
  76. http://data.bter.com/api2/1/ticker/xcn_btc
  77. http://data.bter.com/api2/1/ticker/xcp_btc
  78. http://data.bter.com/api2/1/ticker/xem_btc
  79. http://data.bter.com/api2/1/ticker/xem_cny
  80. http://data.bter.com/api2/1/ticker/xpm_btc
  81. http://data.bter.com/api2/1/ticker/xmr_btc
  82. http://data.bter.com/api2/1/ticker/mg_btc
  83. http://data.bter.com/api2/1/ticker/ifc_ltc
  84. http://data.bter.com/api2/1/ticker/tips_ltc
  85. http://data.bter.com/api2/1/ticker/tix_ltc
  86. http://data.bter.com/api2/1/ticker/etc_eth
  87. http://data.bter.com/api2/1/ticker/zec_btc
  88. http://data.bter.com/api2/1/ticker/zec_cny

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/etp_btc
  11. http://data.bter.com/api2/1/orderBook/etp_cny
  12. http://data.bter.com/api2/1/orderBook/btrx_cny
  13. http://data.bter.com/api2/1/orderBook/btrx_btc
  14. http://data.bter.com/api2/1/orderBook/bts_cny
  15. http://data.bter.com/api2/1/orderBook/cnc_cny
  16. http://data.bter.com/api2/1/orderBook/rep_cny
  17. http://data.bter.com/api2/1/orderBook/bat_cny
  18. http://data.bter.com/api2/1/orderBook/snt_cny
  19. http://data.bter.com/api2/1/orderBook/snt_btc
  20. http://data.bter.com/api2/1/orderBook/snt_eth
  21. http://data.bter.com/api2/1/orderBook/btm_cny
  22. http://data.bter.com/api2/1/orderBook/btm_btc
  23. http://data.bter.com/api2/1/orderBook/omg_cny
  24. http://data.bter.com/api2/1/orderBook/omg_btc
  25. http://data.bter.com/api2/1/orderBook/omg_eth
  26. http://data.bter.com/api2/1/orderBook/pay_cny
  27. http://data.bter.com/api2/1/orderBook/pay_btc
  28. http://data.bter.com/api2/1/orderBook/pay_eth
  29. http://data.bter.com/api2/1/orderBook/bat_eth
  30. http://data.bter.com/api2/1/orderBook/ico_cny
  31. http://data.bter.com/api2/1/orderBook/ico_btc
  32. http://data.bter.com/api2/1/orderBook/ico_eth
  33. http://data.bter.com/api2/1/orderBook/cvc_cny
  34. http://data.bter.com/api2/1/orderBook/cvc_btc
  35. http://data.bter.com/api2/1/orderBook/cvc_eth
  36. http://data.bter.com/api2/1/orderBook/ven_cny
  37. http://data.bter.com/api2/1/orderBook/ven_btc
  38. http://data.bter.com/api2/1/orderBook/storj_cny
  39. http://data.bter.com/api2/1/orderBook/storj_btc
  40. http://data.bter.com/api2/1/orderBook/storj_eth
  41. http://data.bter.com/api2/1/orderBook/eos_cny
  42. http://data.bter.com/api2/1/orderBook/eos_btc
  43. http://data.bter.com/api2/1/orderBook/eos_eth
  44. http://data.bter.com/api2/1/orderBook/doge_cny
  45. http://data.bter.com/api2/1/orderBook/dash_cny
  46. http://data.bter.com/api2/1/orderBook/eth_cny
  47. http://data.bter.com/api2/1/orderBook/etc_cny
  48. http://data.bter.com/api2/1/orderBook/exc_cny
  49. http://data.bter.com/api2/1/orderBook/ftc_cny
  50. http://data.bter.com/api2/1/orderBook/ifc_cny
  51. http://data.bter.com/api2/1/orderBook/nmc_cny
  52. http://data.bter.com/api2/1/orderBook/nxt_cny
  53. http://data.bter.com/api2/1/orderBook/ppc_cny
  54. http://data.bter.com/api2/1/orderBook/shell_cny
  55. http://data.bter.com/api2/1/orderBook/tips_cny
  56. http://data.bter.com/api2/1/orderBook/tix_cny
  57. http://data.bter.com/api2/1/orderBook/xcp_cny
  58. http://data.bter.com/api2/1/orderBook/xmr_cny
  59. http://data.bter.com/api2/1/orderBook/xpm_cny
  60. http://data.bter.com/api2/1/orderBook/xtc_cny
  61. http://data.bter.com/api2/1/orderBook/ltc_btc
  62. http://data.bter.com/api2/1/orderBook/bts_btc
  63. http://data.bter.com/api2/1/orderBook/cnc_btc
  64. http://data.bter.com/api2/1/orderBook/rep_btc
  65. http://data.bter.com/api2/1/orderBook/bat_btc
  66. http://data.bter.com/api2/1/orderBook/hkg_btc
  67. http://data.bter.com/api2/1/orderBook/doge_btc
  68. http://data.bter.com/api2/1/orderBook/dash_btc
  69. http://data.bter.com/api2/1/orderBook/eth_btc
  70. http://data.bter.com/api2/1/orderBook/etc_btc
  71. http://data.bter.com/api2/1/orderBook/ftc_btc
  72. http://data.bter.com/api2/1/orderBook/nmc_btc
  73. http://data.bter.com/api2/1/orderBook/nxt_btc
  74. http://data.bter.com/api2/1/orderBook/ppc_btc
  75. http://data.bter.com/api2/1/orderBook/xtc_btc
  76. http://data.bter.com/api2/1/orderBook/xcn_btc
  77. http://data.bter.com/api2/1/orderBook/xcp_btc
  78. http://data.bter.com/api2/1/orderBook/xem_btc
  79. http://data.bter.com/api2/1/orderBook/xem_cny
  80. http://data.bter.com/api2/1/orderBook/xpm_btc
  81. http://data.bter.com/api2/1/orderBook/xmr_btc
  82. http://data.bter.com/api2/1/orderBook/mg_btc
  83. http://data.bter.com/api2/1/orderBook/ifc_ltc
  84. http://data.bter.com/api2/1/orderBook/tips_ltc
  85. http://data.bter.com/api2/1/orderBook/tix_ltc
  86. http://data.bter.com/api2/1/orderBook/etc_eth
  87. http://data.bter.com/api2/1/orderBook/zec_btc
  88. http://data.bter.com/api2/1/orderBook/zec_cny

7. 历史成交记录 API

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

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

返回从[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/etp_btc
  11. http://data.bter.com/api2/1/tradeHistory/etp_cny
  12. http://data.bter.com/api2/1/tradeHistory/btrx_cny
  13. http://data.bter.com/api2/1/tradeHistory/btrx_btc
  14. http://data.bter.com/api2/1/tradeHistory/bts_cny
  15. http://data.bter.com/api2/1/tradeHistory/cnc_cny
  16. http://data.bter.com/api2/1/tradeHistory/rep_cny
  17. http://data.bter.com/api2/1/tradeHistory/bat_cny
  18. http://data.bter.com/api2/1/tradeHistory/snt_cny
  19. http://data.bter.com/api2/1/tradeHistory/snt_btc
  20. http://data.bter.com/api2/1/tradeHistory/snt_eth
  21. http://data.bter.com/api2/1/tradeHistory/btm_cny
  22. http://data.bter.com/api2/1/tradeHistory/btm_btc
  23. http://data.bter.com/api2/1/tradeHistory/omg_cny
  24. http://data.bter.com/api2/1/tradeHistory/omg_btc
  25. http://data.bter.com/api2/1/tradeHistory/omg_eth
  26. http://data.bter.com/api2/1/tradeHistory/pay_cny
  27. http://data.bter.com/api2/1/tradeHistory/pay_btc
  28. http://data.bter.com/api2/1/tradeHistory/pay_eth
  29. http://data.bter.com/api2/1/tradeHistory/bat_eth
  30. http://data.bter.com/api2/1/tradeHistory/ico_cny
  31. http://data.bter.com/api2/1/tradeHistory/ico_btc
  32. http://data.bter.com/api2/1/tradeHistory/ico_eth
  33. http://data.bter.com/api2/1/tradeHistory/cvc_cny
  34. http://data.bter.com/api2/1/tradeHistory/cvc_btc
  35. http://data.bter.com/api2/1/tradeHistory/cvc_eth
  36. http://data.bter.com/api2/1/tradeHistory/ven_cny
  37. http://data.bter.com/api2/1/tradeHistory/ven_btc
  38. http://data.bter.com/api2/1/tradeHistory/storj_cny
  39. http://data.bter.com/api2/1/tradeHistory/storj_btc
  40. http://data.bter.com/api2/1/tradeHistory/storj_eth
  41. http://data.bter.com/api2/1/tradeHistory/eos_cny
  42. http://data.bter.com/api2/1/tradeHistory/eos_btc
  43. http://data.bter.com/api2/1/tradeHistory/eos_eth
  44. http://data.bter.com/api2/1/tradeHistory/doge_cny
  45. http://data.bter.com/api2/1/tradeHistory/dash_cny
  46. http://data.bter.com/api2/1/tradeHistory/eth_cny
  47. http://data.bter.com/api2/1/tradeHistory/etc_cny
  48. http://data.bter.com/api2/1/tradeHistory/exc_cny
  49. http://data.bter.com/api2/1/tradeHistory/ftc_cny
  50. http://data.bter.com/api2/1/tradeHistory/ifc_cny
  51. http://data.bter.com/api2/1/tradeHistory/nmc_cny
  52. http://data.bter.com/api2/1/tradeHistory/nxt_cny
  53. http://data.bter.com/api2/1/tradeHistory/ppc_cny
  54. http://data.bter.com/api2/1/tradeHistory/shell_cny
  55. http://data.bter.com/api2/1/tradeHistory/tips_cny
  56. http://data.bter.com/api2/1/tradeHistory/tix_cny
  57. http://data.bter.com/api2/1/tradeHistory/xcp_cny
  58. http://data.bter.com/api2/1/tradeHistory/xmr_cny
  59. http://data.bter.com/api2/1/tradeHistory/xpm_cny
  60. http://data.bter.com/api2/1/tradeHistory/xtc_cny
  61. http://data.bter.com/api2/1/tradeHistory/ltc_btc
  62. http://data.bter.com/api2/1/tradeHistory/bts_btc
  63. http://data.bter.com/api2/1/tradeHistory/cnc_btc
  64. http://data.bter.com/api2/1/tradeHistory/rep_btc
  65. http://data.bter.com/api2/1/tradeHistory/bat_btc
  66. http://data.bter.com/api2/1/tradeHistory/hkg_btc
  67. http://data.bter.com/api2/1/tradeHistory/doge_btc
  68. http://data.bter.com/api2/1/tradeHistory/dash_btc
  69. http://data.bter.com/api2/1/tradeHistory/eth_btc
  70. http://data.bter.com/api2/1/tradeHistory/etc_btc
  71. http://data.bter.com/api2/1/tradeHistory/ftc_btc
  72. http://data.bter.com/api2/1/tradeHistory/nmc_btc
  73. http://data.bter.com/api2/1/tradeHistory/nxt_btc
  74. http://data.bter.com/api2/1/tradeHistory/ppc_btc
  75. http://data.bter.com/api2/1/tradeHistory/xtc_btc
  76. http://data.bter.com/api2/1/tradeHistory/xcn_btc
  77. http://data.bter.com/api2/1/tradeHistory/xcp_btc
  78. http://data.bter.com/api2/1/tradeHistory/xem_btc
  79. http://data.bter.com/api2/1/tradeHistory/xem_cny
  80. http://data.bter.com/api2/1/tradeHistory/xpm_btc
  81. http://data.bter.com/api2/1/tradeHistory/xmr_btc
  82. http://data.bter.com/api2/1/tradeHistory/mg_btc
  83. http://data.bter.com/api2/1/tradeHistory/ifc_ltc
  84. http://data.bter.com/api2/1/tradeHistory/tips_ltc
  85. http://data.bter.com/api2/1/tradeHistory/tix_ltc
  86. http://data.bter.com/api2/1/tradeHistory/etc_eth
  87. http://data.bter.com/api2/1/tradeHistory/zec_btc
  88. http://data.bter.com/api2/1/tradeHistory/zec_cny

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

返回数据例子:

	{
		"result":"true",
		"available":{
			"CNY":"1122.16",
			"BTC":"0.83337671",
			"LTC":"94.364",
			"YAC":"0.07161",
			"WDC":"82.35029899"
		},
		"locked":{
			"BTC":"0.0002",
			"YAC":"10.01"
		}
	}
				


获取充值地址API

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

参数数据提交方式:POST

参数:

参数 说明 示例
currency 币种 LTC

返回数据格式:JSON

返回数据例子:

	{
		"result":"true",
		"addr":{
			"LQ6sF9nsQssZST7YtLnMBwE3dVWqoDdrPc "
		}
	}
				


获取充值提现历史API

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

参数数据提交方式:POST

参数:

参数 说明 示例
start 起始UNIX时间 1469092370
end 终止UNIX时间 1469713981

返回数据格式:JSON

返回数据例子:

	{
		"result": "true",
		"deposits": [
			{
				"currency": "BTS",
				"address": "addr1",
				"amount": "800000000",
				"txid": "ab1efaba6a911f62d4eb88a7ac515cfe82f18f41",
				"timestamp": "1469092378",
				"status": "DONE"
			}
		
		],
		"withdraws": [
			{
				"currency": "BTS",
				"address": "addr2",
				"amount": "600000000",
				"txid": "afsad33eda911f62d4eb88fasd7fd89af7d9fs32",
				"timestamp": "1469092378",
				"status": "DONE"
			}
		],
		"message": "Success"
	}
				


下单交易买入API

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

参数数据提交方式:POST

参数:

参数 说明 示例
currencyPair 交易币种对 ltc_btc
rate 价格 0.023
amount 交易量 100

返回数据格式:JSON

返回数据例子:

	{
		"result":"true",
		"orderNumber":"123456",
		"message":"Success"
	}
				

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


下单交易卖出API

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

参数数据提交方式:POST

参数:

参数 说明 示例
pair 交易币种对 ltc_btc
rate 价格 0.023
amount 交易量 100

返回数据格式:JSON

返回数据例子:

	{
		"result":"true",
		"orderNumber":"123456",
		"message":"Success"
	}
				

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


取消下单API

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

参数数据提交方式:POST

参数:

参数 说明 示例
orderNumber 下单单号 123456
currencyPair 交易币种对 ltc_btc

返回数据格式:JSON

返回数据例子:

	{
		"result":"true",
		"message":"Success"
	}
				

取消多个下单API

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

参数数据提交方式:POST

参数:

参数 说明 示例
orders_json 下单单号和pair的json数据 [ { "orderNumber":"7942422" "currencyPair":"ltc_btc" }, { "orderNumber":"7942422" "currencyPair":"ltc_btc" } ]

返回数据格式:JSON

返回数据例子:

	{
		"result":"true",
		"msg":"queued"
	}
				


取消所有下单API

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

参数数据提交方式:POST

参数:

参数 说明 示例
type 下单类型(0:卖出,1:买入,-1:不限制) 0
currencyPair 交易币种对 ltc_btc

返回数据格式:JSON

返回数据例子:

	{
		"result":"true",
		"message":"Success"
	}
				


获取下单状态API

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

参数数据提交方式:POST

参数:

参数 说明 示例
orderNumber 下单单号 123456
currencyPair 交易币种对 ltc_btc

返回数据格式:JSON

返回数据例子:


	{
		"result":"true",
		"order":{
			"id":"15088",
			"status":"cancelled",
			"currencyPair":"btc_cny",
			"type":"sell",
			"rate":811,
			"amount":"0.39901357",
			"initialRate":811,
			"initialAmount":"1"
		},
		"message":"Success"
	}

				


获取我的当前挂单列表API

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

参数数据提交方式:POST

参数:无

返回数据格式:JSON

返回数据例子:


	{
		"result":"true",
		"orders": [
			{
				"orderNumber": "0",
				"type": "sell",
				"rate": 0.0098,
				"amount": "100000",
				"total": "980",
				"currencyPair": "doge_cny",
				"timestamp": "1470648164",
				"status": "open"
			},
			{
				"orderNumber": "0",
				"type": "sell",
				"rate": 0.00000204,
				"amount": "1000204",
				"total": "2.04041616",
				"currencyPair": "doge_btc",
				"timestamp": "1470648850",
				"status": "open"
			}
		],
		"message":"Success"
	}

				


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

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

参数数据提交方式:POST

参数:

参数 说明 示例
currencyPair 交易币种对 ltc_btc
orderNumber 下单单号(可选项) 626150

返回数据格式:JSON

返回数据例子:


	{
		"result":"true",
		"trades":[
		    {
		      "id":"7942422"
		      "orderid":"38100777"
		      "pair":"ltc_btc"
		      "type":"sell"
		      "rate":"0.01719"
		      "amount":"0.0588"
		      "time":"06-12 02:49:11"
		      "time_unix":"1402512551"
		    }
		    {
		      "id":"7942422"
		      "orderid":"38100491"
		      "pair":"ltc_btc"
		      "type":"buy"
		      "rate":"0.01719"
		      "amount":"0.0588"
		      "time":"06-12 02:49:11"
		      "time_unix":"1402512551"
		    }
	  	]
	  	"message":"Success"
	}



				


提现API

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

参数数据提交方式:POST

参数:

参数 说明 示例
currency 提现币种 btc
amount 提现数量 0.01
address 提现地址 1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs

返回数据格式:JSON

返回数据例子:

	{
		"result":"true",
		"message":"Success"
	}
				


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();
		
	} 
?>