How to use Binance API

Hello, My first time here, hopefully many more times to come, I am having difficulty finding a package called “binance.enums”, Ive tried pip install python binance, even pip install binance.enums, no luck.

would love some help,

David

second pic

You have to install the binance library. Start here to find installation
instructions:

In the future, please don’t post images of code or error messages,
unless you use Photoshop to edit your code. Code is text. When posting,
please copy and paste the text, not screenshots or photos of text.

If you have already installed binance, then run this, and copy and paste
the output as text please:

import binance
print(binance.__path__)
print(binance.__version__)

Notice that they are two leading and trailing underscores, not one.

@dagwood101, welcome to this forum and also to the Python community!

Please allow me to give my 2 cents.

The correct pip command to install the python-binance package is pip install python-binance. Notice the hyphen between the words python and binance in the command. I saw that you gave a space between these two words in your post.

Also, please don’t ever use star (asterisk) imports (as you do by from binance.enums import *), unless the documentation explicitly says that it is safe to do so. For a star (asterisk) import to be safe, the API must explicitly assign all proper objects to the __all__ special variable per module in the form of, for example, __all__ = ["foo", "bar"]. As per the example, doing from mymodule import * would then import foo and bar, given that the the module you import foo and bar from is mymodule.py.

However, I neither haven’t noticed anywhere in the python-binance documentation that star (asterisk) imports are documented as safe nor haven’t found any code examples in there that use such imports (which would indicate their safe use).

So, either import a specific enum object from binance.enums (i.e., from binance.enums import SomeEnumName) or all of its enum objects by import binance.enums (and use a specific enum in your code by binance.enums.SomeEnumName). The choice is yours.