Skip to main content

A simple GateCoin REST API client

Project description

Gatecoin Python REST API client

This is a simple Gatecoin python REST API client library that abstracts away the REST for the end user.

Installation

The library can be collected from PyPI like so:

$ pip install gatecoin_api

Usage

The package exposes the GatecoinAPI client class which has methods from the Gatecoin REST API. Public methods may be directly used, for trading methods API credentials need to be set:

api = GatecoinAPI('private_key', 'public_key')

or

api = GatecoinAPI()
api.set_credentials('private_key', 'public_key')

After that trading APIs may be used. Example usage of the Public API:

api = GatecoinAPI()
res = api.get_currency_pairs()
print(res.response_status.message) # 'OK'
print(res.currency_pairs[0].trading_code) # 'BTCEUR'
print(res.currency_pairs[0].base_currency) # 'BTC'
print(res.currency_pairs[0].price_decimal_places) # 1

Implemented methods

  • Trading
    • set_credentials
    • get_balances
    • get_balance
    • get_open_orders
    • get_open_order
    • create_order
    • cancel_order
    • cancel_all_orders
    • get_trade_history
  • Public
    • get_currency_pairs
    • get_market_depth
    • get_order_book
    • get_recent_transactions

Development

To develop or test using this package without installing from PyPI, you can clone the repository and set up the environment in a virtual envirnonment at the root of the working copy:

$ virtualenv venv --python=python3

Activate the virtual environment:

$ source venv/bin/activate

Install development dependencies:

$ pip install -r requirements.txt

Run the interactive python shell and you can use the package as the example given below:

$ python
>>> from gatecoin_api import GatecoinAPI as GA
>>> api = GA()
>>> res = api.get_currency_pairs()
>>> res.response_status.message
'OK'
>>> res.currency_pairs[0].trading_code
'BTCEUR'
>>> res.currency_pairs[0].base_currency
'BTC'
>>> res.currency_pairs[0].quote_currency
'EUR'
>>> res.currency_pairs[0].display_name
'BTC / EUR'
>>> res.currency_pairs[0].name
'BTC / EUR'
>>> res.currency_pairs[0].price_decimal_places
1

Tests

To setup correctly for tests, set valid development API keys and API base URL in your shell environment:

export GTC_TESTS_PRIVATE_KEY=<PRIVATE_KEY>
export GTC_TESTS_PUBLIC_KEY=<PUBLIC_KEY>
export GTC_API_BASE_URL=<API_BASE_URL>

For Windows command line, please use the set command:

set GTC_TESTS_PRIVATE_KEY=<PRIVATE_KEY>
set GTC_TESTS_PUBLIC_KEY=<PUBLIC_KEY>
set GTC_API_BASE_URL=<API_BASE_URL>

To run tests please execute:

$ python setup.py test

If development keys are not set, trading scope tests will fail.

Project details


Download files

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

Files for gatecoin-api, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size gatecoin_api-1.0.0-py3-none-any.whl (9.2 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size gatecoin_api-1.0.0.tar.gz (8.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page