@@ -26,8 +26,12 @@ def post_process(self, before):
2626 return after
2727
2828 def api_query (self , method , req = {}):
29- if (method == "marketdata" or method == "orderdata" ):
30- ret = urllib2 .urlopen (urllib2 .Request ('https://www.cryptsy.com/api.php?method=' + method ))
29+
30+ if (method == "marketdata" or method == "orderdata" or method == "marketdatav2" ):
31+ ret = urllib2 .urlopen (urllib2 .Request ('http://pubapi.cryptsy.com/api.php?method=' + method ))
32+ return json .loads (ret .read ())
33+ elif (method == "singlemarketdata" or method == "singleorderdata" ):
34+ ret = urllib2 .urlopen (urllib2 .Request ('http://pubapi.cryptsy.com/api.php?method=' + method + '&marketid=' + str (marketid )))
3135 return json .loads (ret .read ())
3236 else :
3337 req ['method' ] = method
@@ -47,8 +51,16 @@ def api_query(self, method, req={}):
4751 def getMarketData (self ):
4852 return self .api_query ("marketdata" )
4953
50- def getOrderData (self ):
51- return self .api_query ("orderdata" )
54+ def getMarketDataV2 (self ):
55+ return self .api_query ("marketdatav2" )
56+
57+ def getSingleMarketData (self , marketid ):
58+ return self .api_query ("singlemarketdata" , {'marketid' : marketid })
59+
60+ def getOrderbookData (self , marketid = None ):
61+ if (marketid == None ):
62+ return self .api_query ("orderdata" )
63+ return self .api_query ("singleorderdata" , {'marketid' : marketid })
5264
5365 # Outputs:
5466 # balances_available Array of currencies and the balances availalbe for each
@@ -153,6 +165,27 @@ def myOrders(self, marketid):
153165 return self .api_query ('myorders' , {'marketid' : marketid })
154166
155167
168+ # Inputs:
169+ # marketid Market ID for which you are querying
170+ ##
171+ # Outputs: Array of buy and sell orders on the market representing market depth.
172+ # Output Format is:
173+ # array(
174+ # 'sell'=>array(
175+ # array(price,quantity),
176+ # array(price,quantity),
177+ # ....
178+ # ),
179+ # 'buy'=>array(
180+ # array(price,quantity),
181+ # array(price,quantity),
182+ # ....
183+ # )
184+ # )
185+ def depth (self , marketid ):
186+ return self .api_query ('depth' , {'marketid' : marketid })
187+
188+
156189 # Outputs: Array of all open orders for your account.
157190 # orderid Order ID for this order
158191 # marketid The Market ID this order was created for
@@ -209,3 +242,21 @@ def cancelAllOrders(self):
209242 # net The net total with fees
210243 def calculateFees (self , ordertype , quantity , price ):
211244 return self .api_query ('calculatefees' , {'ordertype' : ordertype , 'quantity' : quantity , 'price' : price })
245+
246+
247+ # Inputs: (either currencyid OR currencycode required - you do not have to supply both)
248+ # currencyid Currency ID for the coin you want to generate a new address for (ie. 3 = BitCoin)
249+ # currencycode Currency Code for the coin you want to generate a new address for (ie. BTC = BitCoin)
250+ ##
251+ # Outputs:
252+ # address The new generated address
253+ def generateNewAddress (self , currencyid = None , currencycode = None ):
254+
255+ if (currencyid != None ):
256+ req = {'currencyid' : currencyid }
257+ elif (currencycode != None ):
258+ req = {'currencycode' : currencycode }
259+ else :
260+ return None
261+
262+ return self .api_query ('generatenewaddress' , req )
0 commit comments