Lightweight Python SDK for the Forebit API
Project description
Forebit Python SDK
Lightweight Python SDK for the Forebit API (customers, payments, wallets).
Installation
pip install forebit
or
poetry add forebit
Setup
Before using the SDK, you'll need to obtain your Business ID and generate an API key from your Forebit account.
Getting Your Business ID
- Log in to your Forebit account
- Navigate to Business Settings > Developer
- Copy your Business ID from the developer settings
Generating an API Key
- Log in to your Forebit account
- Navigate to Account Settings > Developer
- Generate a new API key and copy it securely
⚠️ Important: Keep your API key secure and never commit it to version control.
Usage
import asyncio
from forebit_py import ForebitClient
async def main():
client = ForebitClient(
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 = await client.payments.create(request)
print(payment_response)
# List payments with pagination
payments = await client.payments.list(
search_string='test',
page_size=10,
page_number=1
)
print(payments)
# Get a single payment
single_payment = await client.payments.get('payment-id')
print(single_payment)
# List customers
customers = await client.customers.list(
search_string='email@example.com',
page_size=10,
page_number=1
)
print(customers)
# Get a single customer
customer = await client.customers.get(123)
print(customer)
# List wallets
wallets = await client.wallets.list()
print(wallets)
# List wallet accounts
accounts = await client.wallets.list_accounts('wallet-id')
print(accounts)
# List deposit addresses
addresses = await client.wallets.list_deposit_addresses('wallet-id', 'account-id')
print(addresses)
await client.close()
asyncio.run(main())
API Reference
ForebitClient
Main client class for interacting with the Forebit API.
Constructor Options
api_key(str): Your Forebit API keybusiness_id(str): Your business ID
Payments
create(data: CreatePaymentRequest): Dict[str, Any]
Creates a new payment.
Parameters:
data: Payment creation datapaymentMethods(Optional[Dict[str, List[CryptoCode]]]): 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
Wallets
list(include_deleted: Optional[bool] = None) -> List[Wallet]
Lists all wallets.
Parameters:
include_deleted: Whether to include deleted wallets
list_accounts(wallet_id: str, page_size: Optional[int] = None, page_number: Optional[int] = None) -> WalletAccountListResponse
Lists wallet accounts for a wallet.
Parameters:
wallet_id: Wallet IDpage_size: Number of accounts per pagepage_number: Page number
list_deposit_addresses(wallet_id: str, account_id: str, has_balance: Optional[bool] = None, is_used: Optional[bool] = None) -> List[DepositAddress]
Lists deposit addresses for a wallet account.
Parameters:
wallet_id: Wallet IDaccount_id: Account IDhas_balance: Filter by addresses with balanceis_used: Filter by used addresses
get_deposit_address(wallet_id: str, account_id: str) -> DepositAddress
Gets the current deposit address for a wallet account.
Parameters:
wallet_id: Wallet IDaccount_id: Account ID
create_deposit_address(wallet_id: str, account_id: str) -> DepositAddress
Creates a new deposit address for a wallet account.
Parameters:
wallet_id: Wallet IDaccount_id: Account ID
Types
CreatePaymentRequest
description: Optional[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: Optional[str]- Optional URL to redirect after paymentnotifyUrl: Optional[str]- Optional URL for payment notificationscustomerEmail: Optional[str]- Optional email of the customercustomerIp: Optional[str]- Optional IP address of the customercustomerUserAgent: Optional[str]- Optional user agent of the customer
Payment
id: str- Payment IDname: Optional[str]- Optional namedescription: Optional[str]- Optional descriptionendAmount: float- Payment amountprePaymentAmount: Optional[float]- Pre-payment amountcurrency: str- Currency codestatus: str- Payment statuscreatedAt: str- Creation timestampexpiresAt: Optional[str]- Optional expiration timestamptimeline: Optional[List[TimelineEntry]]- Optional status timelinecustomer: Optional[Customer]- Optional customer infoselectedPaymentMethod: str- Selected payment methodforebitCryptoCharge: Optional[ForebitCryptoCharge]- Optional crypto charge detailsforebitFee: Optional[float]- Optional feeonBehalfOfBusinessId: Optional[int]- Optional business IDnetAmountUsd: Optional[float]- Optional net amount in USDcustomerEmail: Optional[str]- Optional customer email
CustomerStat
id: int- Customer IDemail: str- Customer emailtotalPayments: int- Total paymentstotalSpend: float- Total spendfirstSeen: str- First seen timestamplastPayment: Optional[str]- Optional last payment timestampipAddresses: Optional[List[IpAddress]]- Optional IP addresses
Wallet
id: str- Wallet IDname: str- Wallet nameisActivated: bool- Activation statusisDeleted: bool- Deletion statusdateCreated: str- Creation datepermissions: List[str]- Permissions
WalletAccount
id: str- Account IDblockchainNetwork: str- Blockchain networkname: str- Account namenotes: Optional[str]- Optional notesindex: int- Account indexfreshAddressIndex: int- Fresh address indexnativeBalance: float- Native balanceisFavorite: bool- Favorite statuscreatedAt: str- Creation timestamptokens: List[WalletToken]- Tokensallocation: float- AllocationisStale: bool- Stale status
DepositAddress
id: str- Address IDaddressValue: str- Address valuecreatedAt: str- Creation timestampwalletName: Optional[str]- Optional wallet namebalance: Optional[float]- Optional balanceisUsed: Optional[bool]- Optional used statusreservedUntil: Optional[str]- Optional reservation endhasBalance: Optional[bool]- Optional has balanceindex: Optional[int]- Optional indexisStale: Optional[bool]- Optional stale statustokens: Optional[List[Any]]- Optional tokens
Supported Crypto Codes
The following crypto codes are supported:
- BITCOIN
- LITECOIN
- ETH_TETHER
- ETH_USD_COIN
- ETHEREUM
- TRON
- TRX_TETHER
- TRX_USD_C
- SOL_TETHER
- SOL_USD_COIN
- SOLANA
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 forebit-0.1.1.tar.gz.
File metadata
- Download URL: forebit-0.1.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.0 CPython/3.12.3 Linux/6.14.0-29-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a397952e4f1489b92e0efbba0292e097964d3bdcfb5278d5836e2826a95cf11
|
|
| MD5 |
2bbb76c76c0e1f1131b4787f60a63075
|
|
| BLAKE2b-256 |
42c8d75ee06027194de23d738f8fe2f7b13a008123c6a407a58bea723ce9cbba
|
File details
Details for the file forebit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: forebit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.0 CPython/3.12.3 Linux/6.14.0-29-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f26f864fe55f131b740315fa4558434f292332b357166e4ca6a08fe1c339dcb7
|
|
| MD5 |
a50d8c819f5cfc2f164ab8d25ca2d048
|
|
| BLAKE2b-256 |
985cbd56933ed6bfca6f538e0e53198ae1316f2dd7085162d10c0bea681c6bed
|