MtGox webstream api

时间:2013-03-14 22:00:47

标签: json websocket trading bitcoin

在此doc中,我们有关于网络流MtGox-API的信息。

所以问题。我们有下一个:

query = {
  "id":id,
  "call":apicall,
  "nonce":nonce,
  "currency":cry,
  "parameters":params,
  "item":item
}
output = serialize({
           "op":"call",
           "id":id,
           "call":self.encode_and_sign(serialize(query)),
           "context":"mtgox.com"
         })
ws.send(output)

此代码基于this example

我不能在HTTP-API和Webstreaming API(MtGox)之间建立同构。 你能举出 {apicall,params,item} 的有效例子吗?例如,对于此查询:

https://mtgox.com/api/1/generic/info
https://mtgox.com/api/1/generic/orders
maybe some more complex... 

1 个答案:

答案 0 :(得分:2)

好的,我找到了答案:

我们有基地:

query = {
  "id":id,
  "call":apicall,
  "nonce":nonce,
  "currency":cry,
  "parameters":params,
  "item":item
}

对于网址=〜https://mtgox.com/api/1/generic/info =>结果查询将是下一个:

info_query = {
  "id":"1",
  "call":"private/info",
  "nonce":["0.63745499","1364911980"]
}

res_query = {
  "op":"call",
  "id":"1",
  "call":f_sing_query(apikey,secretkey,info_query),
  "context":"mtgox.com"
}

其中f_sign_query eq为this

如果我们更换“private / info” - > “私人/订单”我们将获得自己的订单。

现在,让我们按日期获取交易

fetch_query = {
  "id":"1",
  "call":"BTCUSD/trades/fetch",
  "nonce":["0.63745499","1364911980"],
  "params":{"since":"1363425799999469"}
}

result_query将是相同的(!info_query< - fetch_query)

现在,add_trade的时刻。示例:我们要为1BTC-56.12345USD出售0.01 BTC

add_query = {
  "id":"1",
  "call":"BTCUSD/order/add",
  "nonce":["0.63745499","1364911980"],
  "params":{"type":"ask","amount_int":str(100000000*0.01),"price_int":str(56.1234*100000)}
}

依旧......