|
| 1 | +# Nicehash python library and command line rest api |
| 2 | + |
| 3 | +Dependacy |
| 4 | +* requests |
| 5 | + |
| 6 | +To install dependencies run following line your favorite shell console |
| 7 | + |
| 8 | + pip install requests |
| 9 | + |
| 10 | + |
| 11 | +## Required data and where to get it |
| 12 | +Following data is needed: |
| 13 | +* api base url: |
| 14 | + * https://api2.nicehash.com - Production environment |
| 15 | + * https://api-test.nicehash.com - Test environment |
| 16 | + |
| 17 | +The documentation how to get organisation id, api key and api key secret is here: |
| 18 | +https://github.com/nicehash/rest-clients-demo |
| 19 | + |
| 20 | +## Library usage |
| 21 | +Nicehash library is contained in file `nicehash.py`. Api is divided in two part: public and private. |
| 22 | + |
| 23 | +Code snipplet for public api |
| 24 | + |
| 25 | + import nicehash |
| 26 | + |
| 27 | + host = 'https://api2.nicehash.com' |
| 28 | + |
| 29 | + public_api = nicehash.public_api(host) |
| 30 | + |
| 31 | + buy_info = public_api.buy_info() |
| 32 | + print(buy_info) |
| 33 | + |
| 34 | + |
| 35 | +Code snipplet for private api |
| 36 | + |
| 37 | + import nicehash |
| 38 | + |
| 39 | + host = 'https://api2.nicehash.com' |
| 40 | + organisation_id = 'Enter your organisation id' |
| 41 | + key = 'Enter your api key' |
| 42 | + secret = 'Enter your secret for api key' |
| 43 | + |
| 44 | + private_api = nicehash.private_api(host, organisation_id, key, secret) |
| 45 | + |
| 46 | + my_accounts = private_api.get_accounts() |
| 47 | + print(my_accounts) |
| 48 | + |
| 49 | + |
| 50 | +Usage of other api calls are shown in `test_bot.py` |
| 51 | + |
| 52 | + |
| 53 | +## Command line usage |
| 54 | +`nicehash.py` can be used as commad line tools |
| 55 | + |
| 56 | +To get help run: |
| 57 | + |
| 58 | + python nicehash.py -h |
| 59 | + |
| 60 | +Result: |
| 61 | + |
| 62 | + Usage: nicehash.py [options] |
| 63 | + |
| 64 | + Options: |
| 65 | + -h, --help show this help message and exit |
| 66 | + -b BASE, --base_url=BASE |
| 67 | + Api base url |
| 68 | + -o ORG, --organization_id=ORG |
| 69 | + Organization id |
| 70 | + -k KEY, --key=KEY Api key |
| 71 | + -s SECRET, --secret=SECRET |
| 72 | + Secret for api key |
| 73 | + -m METHOD, --method=METHOD |
| 74 | + Method for request |
| 75 | + -p PATH, --path=PATH Path for request |
| 76 | + -q PARAMS, --params=PARAMS |
| 77 | + Parameters for request |
| 78 | + -d BODY, --body=BODY Body for request |
| 79 | + |
| 80 | + |
| 81 | +Example usage: |
| 82 | + |
| 83 | + python nicehash.py -b https://api2.nicehash.com -o ca5622bd-bc32-451b-90a4-e9ae1088bade -k 85512ceb-4f37-426e-9fb4-929af9134ed1 -s 11260065-37f9-4875-bbdd-52a59ce7775de2c0596c-5c87-4739-bb60-b3f547612aed -m GET -p /main/api/v2/accounting/accounts/ |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
0 commit comments