Git Product home page Git Product logo

cex.io-api-python's Introduction

cex.io-api-python

CEX.IO API integration. Python sources.

##Intro

  1. Download lib
  2. Get API key and API secret on https://cex.io/trade/profile

##How to use?

###1. Create your python project

###2. Add "import cexapi"

###3. Create class

  api = cexapi.api(username,api_key,api_secret)

username - your username on cex.io api_key - your API key api_secret - your API secret code

###4. Methods and parameters:

####a) API method parametrs

1. couple = ("GHS\BTC" | "BF1\BTC") currency pair
2. since = integer  return trades with tid >= since
3. order_id = integer 
4. ptype = ("sell" | "buy") type of order
5. amount = float 
6. price = float

####b) API methods

1. ticker(couple = 'GHS/BTC') - get ticker
2. order_book(couple = 'GHS/BTC') - get order
3. trade_history(since = 1, couple = 'GHS/BTC') -  get all order
4. balance() - get your balance
5. current_orders(couple = 'GHS/BTC') - get open order
6. cancel_order(order_id) - cancel order №order_id
7. place_order(ptype = 'buy', amount = 1, price = 1, couple = 'GHS/BTC') - create order

####c) Full API documentation: https://cex.io/api

###5. Examples

####Connect and get balance:

import cexapi
api = cexapi.api(username, api_key, api_secret)
print api.balance()
{'timestamp': '1383378763', 'BTC': {'available': '0.04722110', 'orders': '0.00170000'}, 'GHS': {'available': '0.01000000'} }

####Get balance:

print api.balance()
{'timestamp': '1383379054', 'BTC': {'available': '0.04614310', 'orders': '0.00170000'}, 'GHS': {'available': '0.02000000'}}

####Get API ticker:

print api.ticker('GHS/BTC')
{'volume': '7154.78339022', 'last': '0.1078', 'timestamp': '1383379041', 'bid': '0.10778', 'high': '0.10799999', 'low': '0.10670076', 'ask': '0.10780000000000001'}

####Get order book:

print api.order_book('BF1/BTC')
{'timestamp': '1383378967', 'bids': [['1.7', '0.30100000'], ['1.67', '0.00011000'], ['0.8', '0.02070000'], ['0.1002', '0.27748002'], ['0.1', '0.10000000'], ['0.011', '0.30500000'], ['0.009', '1.00000000'], ['0.00171', '0.00100000'], ['0.0012', '1.00000000'], ['0.00116819', '0.50000000'], ['0.001002', '33.00000000'], ['0.001001', '53.00000000'], ['0.001', '3.00000000'], ['0.00097626', '36.00000000'], ['0.0006', '85.00000000'], ['0.00058409', '0.50000000'], ['0.0004889', '0.06823960'], ['0.0003', '1.00000000'], ['0.00029204', '0.90000000'], ['0.0001', '101.00000000']], 'asks': []}

####Get your current active orders:

print api.current_orders('BF1/BTC')
[{'price': '1.7', 'amount': '0.00100000', 'time': '1383378514737', 'type': 'buy', 'id': '6219104', 'pending': '0.00100000'}]

####Place new order:

print api.place_order('buy', 0.001, 1.7, 'BF1/BTC')
{'price': '1.7', 'amount': '0.00100000', 'time': 1383378987622, 'type': 'buy', 'id': '6219145', 'pending': '0.00100000'}

####Place another order (GHS/BTC):

print api.place_order('buy', 0.01, 0.10789, 'GHS/BTC')
{'price': '0.10789', 'amount': '0.01000000', 'time': 1383379024072, 'type': 'buy', 'id': '6219150', 'pending': '0.00000000'}

####Cancel order:

print api.cancel_order(6219145)
True

cex.io-api-python's People

Contributors

beli-sk avatar llazzaro avatar matveyco avatar ulorimi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cex.io-api-python's Issues

Requst for new calls

Could you add the following calls to this api? hashrate, workers & last_price? They're in the php version of your classes and they work great, I'd love to be able to use them in Python as well.

Placing an Order

Hi,

Thanks for the work you've put in with the python API. I'll preface by saying I'm new to python myself.
However, when I attempt to call the code for placing an order, I receive the response: "invalid order type".
The REST api docs on CEX.IO indicate there is an 'order_type' argument to be passed but I have no idea what are considered valid values?

Is a withdraw method possible?

Great APi, thanks for sharing. In my reading of CEX's API (both REST and Websocket), I can not find an API endpoint to withdraw crypto-currency. However, their web-client is able to withdraw from CEX to a crypto-currency address. Has anyone found a way to withdraw crypto-currency funds from CEX programatically?

urllib2.HTTPError: HTTP Error 520: Origin Error

hi my python script close some times with this error :

Traceback (most recent call last):
File "start.py", line 82, in
data = api.balance()
File "/usr/local/lib/python2.7/dist-packages/cexapi-0.1-py2.7.egg/cexapi/cexapi.py", line 66, in balance
return self.api_call('balance', {}, 1)
File "/usr/local/lib/python2.7/dist-packages/cexapi-0.1-py2.7.egg/cexapi/cexapi.py", line 53, in api_call
answer = self.__post(url, param) # Post Request
File "/usr/local/lib/python2.7/dist-packages/cexapi-0.1-py2.7.egg/cexapi/cexapi.py", line 40, in __post
page = urllib2.urlopen(req).read()
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 407, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 520, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 445, in error
return self._call_chain(_args)
File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain
result = func(_args)
File "/usr/lib/python2.7/urllib2.py", line 528, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 520: Origin Error

Can you have a look ?
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.