Lightweight Python SDK for the HoodPay API
Project description
HoodPay Python SDK
Lightweight Python SDK for the HoodPay API (customers, payments).
Installation
pip install hoodpay-py
or
poetry add hoodpay-py
Setup
Before using the SDK, you'll need to obtain your Business ID and generate an API key from your HoodPay account.
- Log in to your HoodPay account
- Navigate to Settings > Developer
- Copy your Business ID and generate a new API key, then copy it securely
⚠️ Important: Keep your API key secure and never commit it to version control.
Usage
from hoodpay_py import HoodPayClient
client = HoodPayClient(
api_key='your-api-key-here',
business_id='your-business-id-here'
)
# Create a payment
request = CreatePaymentRequest(
amount=5.0,
currency='USD',
name='Subscription Test'
)
payment_response = client.payments.create(request)
print(payment)
# List payments with pagination
payments = client.payments.list(
search_string='test',
page_size=10,
page_number=1
)
print(payments)
# Get a single payment
single_payment = client.payments.get('payment-id')
print(single_payment)
# List customers
customers = client.customers.list(
search_string='email@example.com',
page_size=10,
page_number=1
)
print(customers)
# Get a single customer
customer = client.customers.get(123)
print(customer)
# Search for customers and payments
search_results = client.search('alice')
print(search_results)
# Select payment method (public endpoint, no auth required)
select_result = client.livePayments.select_payment_method('payment-id', 'ETHEREUM')
print(select_result)
# Fill customer email (public endpoint)
email_result = client.livePayments.fill_customer_email(
'payment-id',
'customer@example.com'
)
print(email_result)
# Cancel payment (public endpoint)
cancel_result = client.livePayments.cancel_payment('payment-id')
print(cancel_result)
API Reference
HoodPayClient
Main client class for interacting with the HoodPay API.
Constructor Options
api_key(str): Your HoodPay API keybusiness_id(str): Your business ID
Payments
create(data: CreatePaymentRequest): Dict[str, Any]
Creates a new payment.
Parameters:
data: Payment creation datapaymentMethods(optional): Object specifying allowed payment methods. If not provided, all available payment methods will be used.
list(search_string: Optional[str] = None, page_size: Optional[int] = None, page_number: Optional[int] = None) -> Dict[str, Any]
Lists payments with optional search and pagination.
Parameters:
search_string: Search string for filteringpage_size: Number of payments per pagepage_number: Page number
get(payment_id: str): PaymentResponse
Gets a single payment by ID.
Parameters:
payment_id: Payment ID
Customers
list(search_string: Optional[str] = None, page_size: Optional[int] = None, page_number: Optional[int] = None) -> Dict[str, Any]
Lists customers with optional search and pagination.
Parameters:
search_string: Search string for filteringpage_size: Number of customers per pagepage_number: Page number
get(customer_id: int): Dict[str, Any]
Gets a single customer by ID.
Parameters:
customer_id: Customer ID
search(query: str): Dict[str, Any]
Searches for customers and payments matching the provided query string.
Parameters:
query: Search query string
Returns a SearchResult containing matching customers and payments.
Live Payments
selectPaymentMethod(payment_id: str, crypto: CryptoCode) -> Dict[str, Any]
Selects a payment method for a hosted payment page. Automatically detects whether to use XPUB (for LITECOIN/BITCOIN) or direct crypto submission.
Parameters:
payment_id: Payment ID from the hosted pagecrypto: CryptoCode literal
Returns a SelectPaymentMethodResponse with charge details.
fill_customer_email(payment_id: str, email: str) -> Dict[str, Any]
Fills the customer email for a hosted payment page.
Parameters:
payment_id: Payment ID from the hosted pageemail: Customer email address
Returns: Dict with 'message': str
cancel_payment(payment_id: str) -> Dict[str, Any]
Cancels a payment on the hosted page.
Parameters:
payment_id: Payment ID from the hosted page
Returns: Dict with 'message': str
Types
CreatePaymentRequest
description?: str- Optional description of the paymentamount: float- The amount of the paymentcurrency: str- The currency code for the payment (ISO 4217 format, e.g. USD)name: str- The name associated with the paymentredirectUrl?: str- Optional URL to redirect after paymentnotifyUrl?: str- Optional URL for payment notificationscustomerEmail?: str- Optional email of the customercustomerIp?: str | None- Optional IP address of the customercustomerUserAgent?: str | None- Optional user agent of the customer
Payment
id: str- Payment IDname?: str- Optional namedescription?: str- Optional descriptionendAmount: float- Payment amountprePaymentAmount?: float- Pre-payment amountcurrency: str- Currency codestatus: str- Payment statuscreatedAt: str- Creation timestampexpiresAt?: str- Optional expiration timestamptimeline?: TimelineEntry[]- Optional status timelinecustomer?: Customer- Optional customer infopaymentMethod?: str- Optional payment methodselectedPaymentMethod?: str- Optional selected payment methoddirectCryptoCharge?: HoodPayCryptoCharge- Optional crypto charge detailshoodPayFee?: float- Optional feeonBehalfOfBusinessId?: int- Optional business IDnetAmountUsd?: float- Optional net amount in USDcustomerEmail?: str- Optional customer email
CustomerStat
id: int- Customer IDemail: str- Customer emailtotalPayments: int- Total paymentstotalSpend: float- Total spendfirstSeen: str- First seen timestamplastPayment?: str- Optional last payment timestamp
SearchResult
customers: SearchCustomer[]- Matching customerspayments: Payment[]- Matching payments
SelectPaymentMethodResponse
data.chargeId: str- Charge IDdata.chargeCryptoAmount: str- Crypto amount to paydata.chargeCryptoName: str- Crypto namedata.chargeCryptoAddress: str- Crypto address to send tomessage: str- Response message
Supported Crypto Codes
The following crypto codes are supported:
- BITCOIN
- ETHEREUM
- LITECOIN
- BITCOIN_CASH
- ETH_USD_COIN
- ETH_TETHER
- ETH_BNB
- ETH_BUSD
- ETH_MATIC
- ETH_SHIBA_INU
- ETH_APE_COIN
- ETH_CRONOS
- ETH_DAI
- ETH_UNISWAP
Development
# Install dependencies
poetry install
# Run tests
poetry run pytest
# Lint
poetry run ruff check src/
# Format
poetry run ruff format src/
# Type check
poetry run mypy src/
# Build
poetry build
Contributing
Contributions are welcome. Please open an issue or submit a pull request.
License
MIT
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hoodpay_py-0.1.0.tar.gz.
File metadata
- Download URL: hoodpay_py-0.1.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.0 CPython/3.13.5 Linux/6.6.87.2-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2d91e7ecceaa310d84bf7e83bd0b66a3bb0e257eba52d27ddbb86288c99cd7e
|
|
| MD5 |
6c1677b589ff5bcd24b968089740f87f
|
|
| BLAKE2b-256 |
7b4eae38cbfd623c70585c9c7fe666684bf61caadb10e9e27c76e70f618c98e6
|
File details
Details for the file hoodpay_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hoodpay_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.0 CPython/3.13.5 Linux/6.6.87.2-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbe3e6d319a7ee0dc415e27fb45e8df4daadf4c5f8a22b713201b07a066a5094
|
|
| MD5 |
89838e962bc3203005da6f6ac47e1669
|
|
| BLAKE2b-256 |
1edf7279daf2f7990ba0b78fef62a36d0107326b79263bc81e4e0c938e49cb66
|