### GET /me Source: https://github.com/ochen1/honeygainapis-python3/blob/master/README.md Fetches basic information about the authenticated user. ```APIDOC ## GET /me ### Description Retrieves profile information for the user associated with the provided authentication token. ### Method GET ### Endpoint apis.fetch_aboutme(authtoken) ### Parameters #### Query Parameters - **authtoken** (string) - Required - The access token obtained from authentication ### Response #### Success Response (200) - **id** (string) - Honeygain user ID - **email** (string) - Login email - **status** (string) - Registration status - **total_devices** (integer) - Number of connected devices - **email_confirmed** (boolean) - Email confirmation status - **referral_code** (string) - User referral code - **created_at** (datetime) - Account creation timestamp - **features** (list) - Enabled features #### Response Example { "id": "12345", "email": "user@example.com", "status": "active", "total_devices": 1, "email_confirmed": true, "referral_code": "REF123", "created_at": "2023-01-01T00:00:00Z", "features": [] } ``` -------------------------------- ### GET /tos Source: https://github.com/ochen1/honeygainapis-python3/blob/master/README.md Fetches the Terms of Service status for the user. ```APIDOC ## GET /tos ### Description Retrieves the current Terms of Service acceptance status for the authenticated user. ### Method GET ### Endpoint apis.fetch_tosstatus(authtoken) ### Parameters #### Query Parameters - **authtoken** (string) - Required - The access token obtained from authentication ### Response #### Success Response (200) - **version** (string) - Version of TOS accepted - **status** (string) - Current status - **first_terms_accepted_at** (string) - Timestamp of first acceptance #### Response Example { "version": "1.0", "status": "accepted", "first_terms_accepted_at": "2023-01-01T00:00:00Z" } ``` -------------------------------- ### GET /me Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Retrieves detailed information about the authenticated user including account ID, email, and device count. ```APIDOC ## GET /me ### Description Retrieves detailed information about the authenticated user including account ID, email, device count, referral code, and account creation date. ### Method GET ### Endpoint /me ### Response #### Success Response (200) - **id** (string) - User unique identifier - **email** (string) - User email - **status** (string) - Account status - **total_devices** (integer) - Number of active devices - **created_at** (datetime) - Account creation timestamp #### Response Example { "id": "123456", "email": "user@example.com", "status": "active", "total_devices": 3, "created_at": "2023-01-15T10:30:00Z" } ``` -------------------------------- ### GET /traffic/stats Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Retrieves traffic statistics showing bandwidth usage over time. ```APIDOC ## GET /traffic/stats ### Description Retrieves traffic statistics showing bandwidth usage over time. Date strings are automatically converted to Python datetime objects. ### Method GET ### Endpoint /traffic/stats ### Response #### Success Response (200) - **traffic_stats** (array) - List of daily traffic statistics #### Response Example { "traffic_stats": [ {"date": "2023-06-01T00:00:00Z", "gathering_bytes": 1234567890} ] } ``` -------------------------------- ### POST /auth/login Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Generates an authorization token by authenticating with Honeygain using email and password credentials. ```APIDOC ## POST /auth/login ### Description Generates an authorization token by authenticating with Honeygain using email and password credentials. The returned token must be used for all subsequent API calls. ### Method POST ### Endpoint /auth/login ### Request Body - **email** (string) - Required - User email address - **password** (string) - Required - User password ### Request Example { "email": "user@example.com", "password": "your_password" } ### Response #### Success Response (200) - **access_token** (string) - JWT access token for authentication #### Response Example { "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` -------------------------------- ### POST /users Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Creates a new Honeygain user account with the specified email and password. ```APIDOC ## POST /users ### Description Creates a new Honeygain user account with the specified email and password. Optionally accepts a referral coupon code. ### Method POST ### Endpoint /users ### Request Body - **email** (string) - Required - User email address - **password** (string) - Required - User password - **coupon** (string) - Optional - Referral coupon code ### Request Example { "email": "newuser@example.com", "password": "secure_password123", "coupon": "REFERRAL_CODE" } ``` -------------------------------- ### Fetch All Referrals with Pagination Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Retrieves all referrals associated with a user account, automatically handling pagination for accounts with many referrals. Requires an access token. ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Fetch all referrals (automatically handles pagination) referrals = apis.fetch_referrals(token) print(f"Total Referrals: {len(referrals)}") for referral in referrals: print(f"Referral: {referral}") ``` -------------------------------- ### Fetch Devices (Active and Deleted) with Pagination Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Retrieves information about all devices connected to the account, including traffic statistics. Supports fetching both active and deleted devices with automatic pagination. Requires an access token. ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Fetch all active devices active_devices = apis.fetch_devices(token, deleted=False) print(f"Active Devices: {len(active_devices)}") for device in active_devices: print(f"Device ID: {device.get('id')}") print(f"Title: {device.get('title')}") print(f"Status: {device.get('status')}") print("---") # Fetch deleted/removed devices deleted_devices = apis.fetch_devices(token, deleted=True) print(f"Deleted Devices: {len(deleted_devices)}") ``` -------------------------------- ### Manage User Accounts Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Functions to create new accounts, retrieve profile details, check Terms of Service status, and update passwords. ```python import apis # Create user new_user = apis.create_user(email="newuser@example.com", password="secure_password123", coupon="REFERRAL_CODE") # Fetch profile token = apis.gen_authcode("user@example.com", "password")['access_token'] user_info = apis.fetch_aboutme(token) # Check TOS tos_status = apis.fetch_tosstatus(token) # Change password status_code = apis.chg_password(authtoken=token, currentPassword="current_password", newPassword="new_secure_password123") ``` -------------------------------- ### POST /auth/login Source: https://github.com/ochen1/honeygainapis-python3/blob/master/README.md Generates an authentication token using user credentials. ```APIDOC ## POST /auth/login ### Description Generates an authentication token required for subsequent API requests using email and password. ### Method POST ### Endpoint apis.gen_authcode(email, password) ### Parameters #### Request Body - **email** (string) - Required - User account email - **password** (string) - Required - User account password ### Request Example { "email": "user@example.com", "password": "yourpassword" } ### Response #### Success Response (200) - **access_token** (string) - The authorization token for API access #### Response Example { "access_token": "eyJhbGciOiJIUzI1Ni..." } ``` -------------------------------- ### Retrieve Traffic and Earnings Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Methods to fetch bandwidth usage statistics and current account balance information. ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Fetch traffic traffic_data = apis.fetch_trafficstats(token) # Fetch balance balances = apis.fetch_balances(token) print(f"Current Balance: {balances}") ``` -------------------------------- ### Exceptions Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Details on custom exceptions raised by the Honeygain API client. ```APIDOC ## Exceptions ### HoneygainCredentialsError Exception raised when authentication fails due to invalid credentials. ### Usage ```python from exceptions import HoneygainCredentialsError try: token = apis.gen_authcode("invalid@email.com", "wrong_password") except KeyError: raise HoneygainCredentialsError("Invalid email or password provided") ``` ### HoneygainError General exception for unexpected Honeygain API responses or errors. ### Usage ```python from exceptions import HoneygainError try: # API call that might fail result = apis.fetch_balances(token) except Exception as e: raise HoneygainError(f"Honeygain API returned unexpected response: {e}") ``` ``` -------------------------------- ### Fetch Transaction History with Pagination Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Retrieves the complete transaction history for a user account, automatically handling pagination. Timestamps are converted to Python datetime objects. Requires an access token. ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Fetch all transactions (automatically handles pagination) transactions = apis.fetch_transactions(token) for tx in transactions: print(f"Transaction ID: {tx.get('id')}") print(f"Type: {tx.get('type')}") print(f"Amount: {tx.get('amount')}") print(f"Created: {tx['created_at']}") # datetime object print(f"Booked: {tx['booked_at']}") # datetime object print("---") ``` -------------------------------- ### Handle Honeygain Credentials Error Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Demonstrates how to catch and raise a specific `HoneygainCredentialsError` when authentication fails due to invalid user credentials. This exception is raised when an invalid email or password is provided. ```python from exceptions import HoneygainCredentialsError try: token = apis.gen_authcode("invalid@email.com", "wrong_password") except KeyError: raise HoneygainCredentialsError("Invalid email or password provided") ``` -------------------------------- ### Authenticate with Honeygain Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Generates an authorization token using user credentials. This token is required for all subsequent API requests. ```python import apis auth_response = apis.gen_authcode( email="user@example.com", password="your_password" ) access_token = auth_response['access_token'] print(f"Access Token: {access_token}") ``` -------------------------------- ### Device Management API Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Manages devices connected to the user account, including fetching device information, renaming, deleting, and restoring devices. ```APIDOC ## Device Management ### fetch_devices Retrieves information about all devices connected to the account including their traffic statistics. Supports fetching both active and deleted devices with automatic pagination. ### Method GET ### Endpoint /api/devices ### Parameters #### Query Parameters - **token** (string) - Required - Authentication token for the user. - **deleted** (boolean) - Optional - If true, fetches deleted devices. Defaults to false. - **page** (integer) - Optional - Page number for pagination. Defaults to 1. - **limit** (integer) - Optional - Number of items per page. Defaults to 50. ### Request Example ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Fetch all active devices active_devices = apis.fetch_devices(token, deleted=False) print(f"Active Devices: {len(active_devices)}") for device in active_devices: print(f"Device ID: {device.get('id')}") print(f"Title: {device.get('title')}") print(f"Status: {device.get('status')}") print("---") # Fetch deleted/removed devices deleted_devices = apis.fetch_devices(token, deleted=True) print(f"Deleted Devices: {len(deleted_devices)}") ``` ### Response #### Success Response (200) - **devices** (array) - A list of device objects. - **id** (string) - Unique identifier for the device. - **title** (string) - Display name of the device. - **status** (string) - Current status of the device (e.g., 'active', 'inactive'). - **last_seen** (datetime) - Timestamp of the last activity. - **traffic_stats** (object) - Object containing traffic statistics. #### Response Example ```json { "devices": [ { "id": "dev_1a2b3c", "title": "My Laptop", "status": "active", "last_seen": "2023-10-27T11:00:00Z", "traffic_stats": { "total_traffic": 1024000, "current_month_traffic": 512000 } } ] } ``` ### chg_devicename Changes the display name of a device as shown in the Honeygain dashboard. Returns the HTTP status code. ### Method PUT ### Endpoint /api/devices/{deviceID}/name ### Parameters #### Path Parameters - **deviceID** (string) - Required - The ID of the device to rename. #### Request Body - **newname** (string) - Required - The new display name for the device. ### Request Example ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Get device list first devices = apis.fetch_devices(token) device_id = devices[0]['id'] # Change device name status_code = apis.chg_devicename( authtoken=token, deviceID=device_id, newname="My Home Computer" ) if status_code == 200: print("Device renamed successfully") else: print(f"Failed to rename device. Status code: {status_code}") ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Device name updated successfully." } ``` ### del_device Removes a device from the active devices list, moving it to the Removed Devices section. Returns the HTTP status code. ### Method DELETE ### Endpoint /api/devices/{deviceID} ### Parameters #### Path Parameters - **deviceID** (string) - Required - The ID of the device to remove. ### Request Example ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Get device list and select one to delete devices = apis.fetch_devices(token) device_id = devices[0]['id'] # Delete (remove) the device status_code = apis.del_device( authtoken=token, deviceID=device_id ) if status_code == 200: print("Device removed successfully") else: print(f"Failed to remove device. Status code: {status_code}") ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Device removed successfully." } ``` ### res_device Restores a previously removed device back to the active devices list. Returns the HTTP status code. ### Method POST ### Endpoint /api/devices/{deviceID}/restore ### Parameters #### Path Parameters - **deviceID** (string) - Required - The ID of the device to restore. ### Request Example ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Get deleted devices list deleted_devices = apis.fetch_devices(token, deleted=True) device_id = deleted_devices[0]['id'] # Restore the device status_code = apis.res_device( authtoken=token, deviceID=device_id ) if status_code == 200: print("Device restored successfully") else: print(f"Failed to restore device. Status code: {status_code}") ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Device restored successfully." } ``` ``` -------------------------------- ### Fetch Referrals API Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Retrieves all referrals associated with the user account. Automatically handles pagination for accounts with many referrals. ```APIDOC ## GET /api/referrals ### Description Retrieves all referrals associated with the user account. Automatically handles pagination for accounts with many referrals. ### Method GET ### Endpoint /api/referrals ### Parameters #### Query Parameters - **token** (string) - Required - Authentication token for the user. - **page** (integer) - Optional - Page number for pagination. Defaults to 1. - **limit** (integer) - Optional - Number of items per page. Defaults to 50. ### Request Example ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Fetch all referrals (automatically handles pagination) referrals = apis.fetch_referrals(token) print(f"Total Referrals: {len(referrals)}") for referral in referrals: print(f"Referral: {referral}") ``` ### Response #### Success Response (200) - **referrals** (array) - A list of referral objects. - **id** (string) - Unique identifier for the referral. - **user_id** (string) - The ID of the referred user. - **joined_at** (datetime) - Timestamp when the referral joined. #### Response Example ```json { "referrals": [ { "id": "ref_abc123", "user_id": "user_xyz789", "joined_at": "2023-10-26T09:00:00Z" } ] } ``` ``` -------------------------------- ### Restore Deleted Device Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Restores a previously removed device back to the active devices list. Requires the user's access token and the device ID of the device to be restored. Returns the HTTP status code of the operation. ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Get deleted devices list deleted_devices = apis.fetch_devices(token, deleted=True) device_id = deleted_devices[0]['id'] # Restore the device status_code = apis.res_device( authtoken=token, deviceID=device_id ) if status_code == 200: print("Device restored successfully") else: print(f"Failed to restore device. Status code: {status_code}") ``` -------------------------------- ### Handle General Honeygain API Errors Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Provides a general exception handler for unexpected Honeygain API responses or errors. Catches any exception during an API call and raises a `HoneygainError` with a descriptive message. ```python from exceptions import HoneygainError try: # API call that might fail result = apis.fetch_balances(token) except Exception as e: raise HoneygainError(f"Honeygain API returned unexpected response: {e}") ``` -------------------------------- ### Fetch Transactions API Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Retrieves the complete transaction history for the user account with automatic pagination. Timestamps are converted to Python datetime objects. ```APIDOC ## GET /api/transactions ### Description Retrieves the complete transaction history for the user account with automatic pagination. Timestamps are converted to Python datetime objects. ### Method GET ### Endpoint /api/transactions ### Parameters #### Query Parameters - **token** (string) - Required - Authentication token for the user. - **page** (integer) - Optional - Page number for pagination. Defaults to 1. - **limit** (integer) - Optional - Number of items per page. Defaults to 50. ### Request Example ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Fetch all transactions (automatically handles pagination) transactions = apis.fetch_transactions(token) for tx in transactions: print(f"Transaction ID: {tx.get('id')}") print(f"Type: {tx.get('type')}") print(f"Amount: {tx.get('amount')}") print(f"Created: {tx['created_at']}") # datetime object print(f"Booked: {tx['booked_at']}") # datetime object print("---") ``` ### Response #### Success Response (200) - **transactions** (array) - A list of transaction objects. - **id** (string) - Unique identifier for the transaction. - **type** (string) - Type of transaction (e.g., 'deposit', 'withdrawal'). - **amount** (number) - The amount of the transaction. - **created_at** (datetime) - Timestamp when the transaction was created. - **booked_at** (datetime) - Timestamp when the transaction was booked. #### Response Example ```json { "transactions": [ { "id": "tx_12345", "type": "earning", "amount": 1000, "created_at": "2023-10-27T10:00:00Z", "booked_at": "2023-10-27T10:05:00Z" } ] } ``` ``` -------------------------------- ### Change Device Name Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Changes the display name of a specific device in the Honeygain dashboard. Requires the user's access token, the device ID, and the new desired name. Returns the HTTP status code of the operation. ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Get device list first devices = apis.fetch_devices(token) device_id = devices[0]['id'] # Change device name status_code = apis.chg_devicename( authtoken=token, deviceID=device_id, newname="My Home Computer" ) if status_code == 200: print("Device renamed successfully") else: print(f"Failed to rename device. Status code: {status_code}") ``` -------------------------------- ### Delete Device Source: https://context7.com/ochen1/honeygainapis-python3/llms.txt Removes a device from the active devices list, moving it to the 'Removed Devices' section. Requires the user's access token and the device ID. Returns the HTTP status code of the operation. ```python import apis token = apis.gen_authcode("user@example.com", "password")['access_token'] # Get device list and select one to delete devices = apis.fetch_devices(token) device_id = devices[0]['id'] # Delete (remove) the device status_code = apis.del_device( authtoken=token, deviceID=device_id ) if status_code == 200: print("Device removed successfully") else: print(f"Failed to remove device. Status code: {status_code}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.