Python wrapper for the Honeygain API.
Project description
Honeygain.py
A python wrapper to interact with Honeygain's dashboard API.
Installation
$ pip install honeygain.py
Usage
import honeygain
from honeygain.schemas import UserProfile
EMAIL = 'mike@example.com'
PASS = 'V3ryZ3cUReP@sSw0rD' # TODO: remove my totally real password
# log in...
client = honeygain.Client()
client.login(EMAIL, PASS)
# alternatively, if you already have a token:
# client.token = 'myAccessToken'
profile: UserProfile = client.get_profile()
print(f'--- Logged in as {profile.email} ---')
print(f'Created at: {profile.created_at}')
print(f'JumpTask enabled: {profile.jumptask_mode}')
print(f'Active devices: {profile.active_device_count} / {profile.total_device_count}')
A note about logging in
Due to the way this library works, running the above example will generate a new access token every time it's ran. Because of this, it is HEAVILY recommended that you store the access token somewhere and cache it so you do not have to call login() over and over.
Honeygain has set a very tight ratelimit on how often you can call the login endpoint, and they WILL prevent you from logging in again after a couple tries. When this happens, you are effectively locked out of your account and will have to try again the next day. That is, unless you have cached your access token like the smart person you are.
A very simple example to cache access tokens:
import honeygain
client = honeygain.Client()
# getting a stored access token
with open('token.txt', 'r') as file:
client.token = file.read().strip()
# storing an access token after logging in
with open('token.txt', 'w+') as file:
file.write(client.token)
Access tokens last for a very long time. If your token has expired, the API will tell you by raising
a honeygain.HTTPException
.
If you do get yourself locked out
Two options:
- Accept defeat. Your code is bad and you should feel bad. Try again tomorrow, or in an hour if you're lucky.
- If you are still logged in on a web browser:
- Open the honeygain dashboard
- Open devtools -> storage -> local storage
- Your token is listed under the
JWT
key for the dashboard domain.
Implemented endpoints
The base URL for all endpoints is https://dashboard.honeygain.com/api/v{version}
. Version is 1 unless otherwise noted.
This library currently supports all endpoints of the Honeygain API as used by the official dashboard, and it is therefore able to get the same information and perform the same actions as you normally would through the dashboard.
General account
-
POST /users/tokens
- Logging in with email + password -
GET /users/me
- Account details -
GET /users/tos
- ToS statistics -
GET /devices
- Currently active devices and stats about them. Note: uses API v2.
Notifications
-
GET /notifications?user_id=<user id>
Get your notifications (why is there a user ID here??) -
POST /notifications/<notif ID>/actions
Interact with the notification -
GET /contest_winnings
Get the winnings of a contest. Can only be called after interacting with the notification as above.
Lifetime earnings
-
GET /earnings/jt
- Lifetime earnings in JumpTask mode -
GET /users/balances
- Lifetime earnings for "normal" mode, as well as the minimum payout threshold -
GET /referrals/earnings
- Lifetime referral stats and earnings
Daily earnings
-
GET /earnings/stats
- Detailed daily earnings in "normal" mode for the past month -
GET /jt-earnings/stats
- Detailed daily earnings in JumpTask mode for the past month -
GET /earnings/wallet-stats
- Daily earnings broken down into normal and JumpTask modes.
Current day earnings
-
GET /earnings/today
- Current day earnings for "normal" mode, with detailed information about the origin of your earnings. -
GET /jt-earnings/today
- Current day earnings for JumpTask mode, with detailed information about the origin of your earnings.
Contributing
I realize that the way this library works right now might not be very intuitive at first - the issue is simply that Honeygain's (private!) API is not great. I've tried to introduce some improvements here and there, such as making property names more_pep8_compliant, but there's still a long way to go!
If you have any suggestions for the library, I'd be happy to accept pull requests. Please do create an issue before making large modifications though, so we can discuss the changes before you spend your entire afternoon on it :p
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file Honeygain.py-1.3.0.tar.gz
.
File metadata
- Download URL: Honeygain.py-1.3.0.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e76003f58752a6a5d0f69a29a285c1d2136855ce2573700eb602e5235d648785 |
|
MD5 | b3e3ab0a79658f6838368899a6687f4a |
|
BLAKE2b-256 | 573ff3ceb82cc000c50bd9121b0fda9d35b336e1740e87d17a21b3b81bb917eb |
File details
Details for the file Honeygain.py-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: Honeygain.py-1.3.0-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8339f4067328bb5eb2ca14dce3eaf3edceaa8c935b7a47ad0b6b55b5b04cc4c1 |
|
MD5 | b0a01c4577891e6d3d1d7a6dd0a3eb97 |
|
BLAKE2b-256 | e719c6e40a138963a01498d09247797c891293e1708bde696de1d0a1666bbc15 |