Skip to main content

coinzo REST API python implementation

Project description

python-coinzo 0.1.0

PyPI version License Travis CI Coverage Status Wheel Python requirement

python-coinzo is a simple Python wrapper for coinzo REST API. It requires Python 3.6+


Features

  • Implementation of REST endpoints
  • Simple handling of authentication
  • Response exception handling

Quick Start

  • Register an account with coinzo.
  • Generate an API Key and assign relevant permissions.
  • Install the python package using the following command.
pip install python-coinzo

Examples

Initializing the API Client

from coinzo.api import coinzo
coinzo = coinzo("<your_api_key>", "<your_api_secret>")

Fetch ticker information for all trading pairs

tickers = coinzo.get_all_tickers()
{
    "BTC-TRY": {
        "low": "37972",
        "high": "41289",
        "last": "41019",
        "volume": "445.04",
        "daily_change": "2255",
        "daily_change_percentage": "5.81"
    },
    "CNZ-TRY": {
        "low": "0.078402",
        "high": "0.085452",
        "last": "0.084379",
        "volume": "14396298.29",
        "daily_change": "0.005059",
        "daily_change_percentage": "6.37"
    }
}

Fetch ticker information for BTC-TRY pair

ticker = coinzo.get_ticker("BTC-TRY")
{
    "BTC-TRY": {
        "low": "37972",
        "high": "41289",
        "last": "41019",
        "volume": "445.04",
        "daily_change": "2255",
        "daily_change_percentage": "5.81"
    }
}

Fetch market depth (order book info) for HOT-TRY pair

depth = coinzo.get_order_book(pair="HOT-TRY")
{
    "asks": [{
        "price": 0.0076643,
        "amount": 67637,
        "count": 1
    }, {
        "price": 0.007704,
        "amount": 112916,
        "count": 1
    }],
    "bids": [{
        "price": 0.0076311,
        "amount": 129139,
        "count": 1
    }, {
        "price": 0.0076246,
        "amount": 78436,
        "count": 1
    }],
    "total": {
        "bid": 350621.63142392,
        "ask": 54458830.79696769
    }
}

Fetch latest trades for HOT-TRY pair

trades = coinzo.get_latest_trades(pair="HOT-TRY")
[{
    "price": 0.0076221,
    "amount": 33597,
    "side": "BUY",
    "created_at": 1557603438
}, {
    "price": 0.0076235,
    "amount": 27715,
    "side": "SELL",
    "created_at": 1557603378
}]

Place a market buy order

order = coinzo.place_market_buy_order(pair="NEO-TRY", amount="1")
{
    "id": "123456789012345678"
}

Place a limit buy order

order = coinzo.place_limit_buy_order(
    pair="NEO-TRY",
    amount="1",
    limit_price="50.01",
)
{
    "id": "123456789012345678"
}

Place a stop market buy order

order = coinzo.place_stop_market_buy_order(
    pair="NEO-TRY",
    amount="1",
    stop_price="59.99",
)
{
    "id": "123456789012345678"
}

Place a stop limit buy order

order = coinzo.place_stop_limit_buy_order(
    pair="NEO-TRY",
    amount="1",
    limit_price="50.01",
    stop_price="50.99",
)
{
    "id": "123456789012345678"
}

Fetch an order

order = coinzo.get_order(order_id="123456789012345678")
{
    "id": "123456789012345678",
    "pair": "NEO-TRY",
    "side": "BUY",
    "type": "LIMIT",
    "limit_price": 50.01,
    "stop_price": 0,
    "original_amount": 1,
    "executed_amount": 0,
    "remaining_amount": 1,
    "active": true,
    "cancelled": false,
    "updated_at": 1557604055
}

Fetch all open orders

orders = coinzo.get_open_orders()
[{
    "id": "123456789012345678",
    "pair": "NEO-TRY",
    "side": "BUY",
    "type": "LIMIT",
    "limit_price": 50.01,
    "stop_price": 0,
    "original_amount": 1,
    "executed_amount": 0,
    "remaining_amount": 1,
    "active": true,
    "cancelled": false,
    "updated_at": 1557604055
}, {
    "id": "123456789012345678",
    "pair": "HOT-TRY",
    "side": "SELL",
    "type": "LIMIT",
    "limit_price": 0.1,
    "stop_price": 0,
    "original_amount": 100000,
    "executed_amount": 0,
    "remaining_amount": 100000,
    "active": true,
    "cancelled": false,
    "updated_at": 1549109505
}]

Fetch a list of recent fills

fills = coinzo.get_fills()
[{
    "id": "123456789012345678",
    "order_id": "12345987630291234",
    "coin": "NEO",
    "fiat": "TRY",
    "side": "BUY",
    "price": 53.383,
    "amount": 30,
    "taker": true,
    "fee": 20.29591797,
    "used_cnz": true,
    "cnz_bonus": 0,
    "created_at": 1557446830
}, {
    "id": "987654321098765432",
    "order_id": "12345987671349876",
    "coin": "CNZ",
    "fiat": "TRY",
    "side": "SELL",
    "price": 0.078907,
    "amount": 20350,
    "taker": true,
    "fee": 3.2115149,
    "used_cnz": false,
    "cnz_bonus": 4.38821466,
    "created_at": 1557446668
}]

Cancel an order

coinzo.cancel_order(order_id="123456789012345678")
true

Cancel all open orders

coinzo.cancel_all_orders()
true

Fetch a deposit address for BTC

address = coinzo.get_deposit_address(asset="BTC")
{
    "asset": "BTC",
    "address": "34cFKPBTaq12NKTNfs4HmhB9876SQDZfoE"
}

Fetch list of deposits

limit and page are optional, defaults: limit=100, page=1

deposits = coinzo.get_deposit_history(limit=2, page=2)
[{
    "id": "123456789012345678",
    "tx_id": "201901011234A567890",
    "asset": "TRY",
    "address": "CZ12345678",
    "amount": 100,
    "confirmations": 1,
    "completed": true,
    "created_at": 1554702411
}, {
    "id": "987654321098765432",
    "tx_id": "abc01de2fabcdefabc345d6e060c15a15364eee8b449eb63e10c6f809d44d987",
    "asset": "EOS",
    "address": "EOS123456789",
    "amount": 10,
    "confirmations": 3,
    "completed": true,
    "created_at": 1553425199
}]

Withdraw 10 EOS

coinzo.withdraw(
    asset="EOS",
    address="EOS123456789",
    amount="10",
    memo="EOS6Uabc1Ggua2stBtyqxiKxyzzVSdZSXYCFwZ9AB35cDefECxyzm",
)
{
    "amount": 10,
    "asset": "EOS",
    "id": "450693154343354369"
}

Fetch list of withdrawals

limit and page are optional, defaults: limit=100, page=1

withdrawals = coinzo.get_withdrawal_history(limit=1, page=3)
[
  {
    "id": "321425023135652252",
    "tx_id": "95DD0893F9B2F0CBFEACDAF11672BAFC5BE1F097F450CD51F0420B44D81BF3C1",
    "asset": "XRP",
    "address": "rDQGVYCKC3StBmJV6my9uL1Dn9q7TzEGqS:964641378",
    "amount": 19,
    "status": 1,
    "created_at": 1529758242
  }
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-coinzo-0.1.1.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distribution

python_coinzo-0.1.1-py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page