0

First of all a disclaimer: I am using python and anaconda and jupyter all for the first time, so it might be something basic. I pasted the following code into a new Jupyter note from this url: https://github.com/t0pep0/btc-e.api.python/blob/master/btceapi.py

After filling in my own API and secret API key, I tried to get this running:

getInfo()

But I ran into this error:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-14-c63c8cc1259c> in <module>()
     96 
     97 
---> 98 getInfo()

NameError: name 'getInfo' is not defined

I checked the following solutions:

But since the class and function are both defined in the correct order in the script I copied, there must be something else going on.

Community
  • 1
  • 1
DaReal
  • 597
  • 3
  • 10
  • 24

2 Answers2

3

getInfo is a class method. So you need to instanciate an api object before calling it. You could try something like this.

myApi = api()
myApi.getInfo()
Håken Lid
  • 22,318
  • 9
  • 52
  • 67
  • Thank you! This worked by filling in: `myApi = api('myApiKey', 'mySecretApiKey')` and then running the `myApi.getInfo()` – DaReal Jan 31 '16 at 14:51
1

Some general comments, as Hakens answer is your problem. Don't copy this script into a cell in the notebook like this (I believe this is what you are doing) You can either manually install to site packages (there doesn't appear to be a setup script for this module), or have the file in the same directory as the notebook. Then you can run

from btcapi import api

and proceed with Haken's answer (with appropriate arguments to the init method)

user3684792
  • 2,542
  • 2
  • 18
  • 23
  • I was indeed copying it into a cell/paragraph in a note. Being a newbie in python and jupyter, I don't get what you mean by installing to site packages... But by your second option do you mean: creating a new folder in the localhost:8888/tree, save the script as btcapi.py and then create a note in that same folder where I call the code you gave? – DaReal Jan 31 '16 at 14:57
  • I tried the steps I mentioned above and got it working, thanks. – DaReal Jan 31 '16 at 19:27