Skip to main content

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

  1. Log in to your Forebit account
  2. Navigate to Business Settings > Developer
  3. Copy your Business ID from the developer settings

Generating an API Key

  1. Log in to your Forebit account
  2. Navigate to Account Settings > Developer
  3. 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 key
  • business_id (str): Your business ID

Payments

create(data: CreatePaymentRequest): Dict[str, Any]

Creates a new payment.

Parameters:

  • data: Payment creation data
    • paymentMethods (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 filtering
  • page_size: Number of payments per page
  • page_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 filtering
  • page_size: Number of customers per page
  • page_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 ID
  • page_size: Number of accounts per page
  • page_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 ID
  • account_id: Account ID
  • has_balance: Filter by addresses with balance
  • is_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 ID
  • account_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 ID
  • account_id: Account ID

Types

CreatePaymentRequest

  • description: Optional[str] - Optional description of the payment
  • amount: float - The amount of the payment
  • currency: str - The currency code for the payment (ISO 4217 format, e.g. USD)
  • name: str - The name associated with the payment
  • redirectUrl: Optional[str] - Optional URL to redirect after payment
  • notifyUrl: Optional[str] - Optional URL for payment notifications
  • customerEmail: Optional[str] - Optional email of the customer
  • customerIp: Optional[str] - Optional IP address of the customer
  • customerUserAgent: Optional[str] - Optional user agent of the customer

Payment

  • id: str - Payment ID
  • name: Optional[str] - Optional name
  • description: Optional[str] - Optional description
  • endAmount: float - Payment amount
  • prePaymentAmount: Optional[float] - Pre-payment amount
  • currency: str - Currency code
  • status: str - Payment status
  • createdAt: str - Creation timestamp
  • expiresAt: Optional[str] - Optional expiration timestamp
  • timeline: Optional[List[TimelineEntry]] - Optional status timeline
  • customer: Optional[Customer] - Optional customer info
  • selectedPaymentMethod: str - Selected payment method
  • forebitCryptoCharge: Optional[ForebitCryptoCharge] - Optional crypto charge details
  • forebitFee: Optional[float] - Optional fee
  • onBehalfOfBusinessId: Optional[int] - Optional business ID
  • netAmountUsd: Optional[float] - Optional net amount in USD
  • customerEmail: Optional[str] - Optional customer email

CustomerStat

  • id: int - Customer ID
  • email: str - Customer email
  • totalPayments: int - Total payments
  • totalSpend: float - Total spend
  • firstSeen: str - First seen timestamp
  • lastPayment: Optional[str] - Optional last payment timestamp
  • ipAddresses: Optional[List[IpAddress]] - Optional IP addresses

Wallet

  • id: str - Wallet ID
  • name: str - Wallet name
  • isActivated: bool - Activation status
  • isDeleted: bool - Deletion status
  • dateCreated: str - Creation date
  • permissions: List[str] - Permissions

WalletAccount

  • id: str - Account ID
  • blockchainNetwork: str - Blockchain network
  • name: str - Account name
  • notes: Optional[str] - Optional notes
  • index: int - Account index
  • freshAddressIndex: int - Fresh address index
  • nativeBalance: float - Native balance
  • isFavorite: bool - Favorite status
  • createdAt: str - Creation timestamp
  • tokens: List[WalletToken] - Tokens
  • allocation: float - Allocation
  • isStale: bool - Stale status

DepositAddress

  • id: str - Address ID
  • addressValue: str - Address value
  • createdAt: str - Creation timestamp
  • walletName: Optional[str] - Optional wallet name
  • balance: Optional[float] - Optional balance
  • isUsed: Optional[bool] - Optional used status
  • reservedUntil: Optional[str] - Optional reservation end
  • hasBalance: Optional[bool] - Optional has balance
  • index: Optional[int] - Optional index
  • isStale: Optional[bool] - Optional stale status
  • tokens: 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forebit-0.1.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forebit-0.1.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

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

Hashes for forebit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6a397952e4f1489b92e0efbba0292e097964d3bdcfb5278d5836e2826a95cf11
MD5 2bbb76c76c0e1f1131b4787f60a63075
BLAKE2b-256 42c8d75ee06027194de23d738f8fe2f7b13a008123c6a407a58bea723ce9cbba

See more details on using hashes here.

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

Hashes for forebit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f26f864fe55f131b740315fa4558434f292332b357166e4ca6a08fe1c339dcb7
MD5 a50d8c819f5cfc2f164ab8d25ca2d048
BLAKE2b-256 985cbd56933ed6bfca6f538e0e53198ae1316f2dd7085162d10c0bea681c6bed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page