Parad0x
Parad0x

Reputation: 1

Poloniex Python Wrapper

I am fairly new to Python and I have been trying to get the Python Poloniex wrapper to work but am a little unsure about the usage. The Code is posted on Github here

Is someone able to shed a little light on firstly where I put my API Key & Secret?

I am thinking it would go into this section?

class poloniex:
    def __init__(self, APIKey, Secret):
        self.APIKey = APIKey # Key here?
        self.Secret = Secret # Secret here?

Once I have the keys & secret all set up, what is the correct syntax for calling the various functions i.e A balance call or buy call for example?

Is it just api_query('returnBalances') or poloniex.returnBalances('returnBalances')as an example?

I think a lot of people could use some direction and help on this!

Upvotes: 0

Views: 443

Answers (3)

s4w3d0ff
s4w3d0ff

Reputation: 1190

I rewrote the wrapper that poloniex has linked on the api page years ago on github: https://github.com/s4w3d0ff/python-poloniex

pip install https://github.com/s4w3d0ff/python-poloniex/archive/v0.4.7.zip

It works on python 2.7 & 3.x

from poloniex import Poloniex
polo = Poloniex('your-Api-Key-Here-xxxx','yourSecretKeyHere123456789')
balance = polo('returnBalances')
print("I have %s BTC!" % balance['BTC'])

Upvotes: 0

Willy D
Willy D

Reputation: 1

First of all, before you even go to using your Poloniex API key, you have to fix the code. The python wrapper is only working if you are using Pyton 2.x and it is not working with Python 3.x. The major change to make it usable is to replace the urlib2 library with the corresponding urlib.request library for Python 3.x . Overall, the wrapper is crap and it will take a lot of knowledge and time to fix it for your needs, and only then you will need your API key and password. Its worth it to keep learning Python even to just fixing the wrapper. You might have more benefit from the Python knowledge than using the wrapper. I tried to use the wrapper without knowing much Python and it was super frustrating. I kept reading and replaced the wrapper completely with my own code and it felt great. Good luck.

Upvotes: 0

A. STEFANI
A. STEFANI

Reputation: 6737

According to your code poloniex is a class, the api_key and secret have to be given at the initialization, so you may try this code:

p_api=poloniex("your_api_key_here","your_secret_here") #initialize the poloniex class with api key & secret
balance=p_api.returnBalances() #get balance
print(balance) #show balance

Upvotes: 0

Related Questions