Giter Site home page Giter Site logo

python-viabtc-api's Introduction

python-viabtc-api

API Wrapper for ViaBTC exchange server - open source cryptocurrency exchange engine. Also works with the original exchange server.

Installation

This API is very simple. The installation is just the downloading sources from github

git clone https://github.com/testnet-exchange/python-viabtc-api
cd python-viabtc-api
pip3 install -r requirements.txt

Usage

The basic usage:

from ViaBTCAPI.ViaBTCAPI import ViaBTCAPI

exchange_url = "http://localhost:8080/"  # choose to your exchange url
api = ViaBTCAPI(exchange_url)

resp = api.market_list()
market_names = [m["name"] for m in resp["result"]]
print("Exchange markets: ", market_names)

print()
print("Orderbooks:")
for market in market_names:
    ob = api.order_depth(market=market)
    print(market, ob["result"])

More usage code examples you can find in examples folder. Read the code first, it may contain some hardcoded constants that should be changed.


Working with the exchange server

Since I have had a lot of troubles with the original exchange server by ViaBTC, I've decided to write this tutorial for beginners. I hope that helps.

Install exchange

For me the easiest way to install the exchange was found in bitlum's fork of the original ViaBTC repository. You need docker and docker-compose (up-to-date) to launch this installation script.

git clone https://github.com/testnet-exchange/viabtc_exchange_server
cd viabtc_exchange_server/docker
sudo docker-compose up

That's it! It successfully run on Ubuntu and Debian servers, but failed on macOS (there were some disk path errors that I balieve can be easily fixed if you are familiar with docker or stackoverflow).

Connect to exchange local network

Docker-compose creates the local net for all dockers images. Take a look at docker-compose file: you may notice the local ip addresses near every docker container. We will use the address of accesshttp container to make API requests.

As all of that stuff is happening on the remote server's local network, we need to make some port forwarding from it to out development machine (in my case this is my macbook laptop):

ssh user@<your-server-id-address-> -L 8080:192.168.18.45:8080 -N -f

where 192.168.18.45 is the ip address of accesshttp container and 8080 is its port.

And now you can send API requests to exchange_url = "http://localhost:8080"


I spent a few hours to figure out how to run the exchange and make requests to it. If this tutorial helped you, smash the star button at the top of the page. And fell free to make Pull Requests with some additional functionallity.

Happy Coding!

python-viabtc-api's People

Contributors

ohld 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-viabtc-api's Issues

deploy on centos

Hi,I deploy bitlum/exchange on centos. The container bitlum/exchange is exited because of "./accesshttp.exe: init process fail: -29: Operation not permitted"

how use order.put_limit

hi,i use curl http://127.0.0.1:8080/ -d '{"method": "order.put_limit", "params": [1,"DSHBCH",2,"100","1.5","0.0001","0.0001",""], "id": 1}'

response:
{
"error": {
"code": 10,
"message": "balance not enough"
},
"result": null,
"id": 1
}

i don't know balance not enough what‘s maen.

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.