Python SDK
The official Python SDK for Crowd.Credit, compatible with Python 3.9+.
Installation
pip install crowd-credit
Setup
from crowd_credit import CrowdCreditClient
client = CrowdCreditClient(api_key="your_api_key")
Usage Examples
Account Management
# Get account details
account = client.accounts.me()
print(f"Account: {account.wallet_address}")
# Get KYC status
kyc = client.accounts.get_kyc_status()
Deposits
# List deposits
deposits = client.deposits.list(limit=10)
# Get deposit summary
summary = client.deposits.get_summary()
print(f"Total deposited: ${summary.total_value}")
Credit
# Get credit line
credit_line = client.credit.get_line()
print(f"Available: ${credit_line.available}")
print(f"Health factor: {credit_line.health_factor}")
# Get graduation tier
tier = client.credit.get_tier()
print(f"Current tier: {tier.name}")
Yield
# Get yield summary
yield_summary = client.yield_.get_summary()
print(f"Total earned: ${yield_summary.total_earned}")
Async Support
import asyncio
from crowd_credit import AsyncCrowdCreditClient
async def main():
client = AsyncCrowdCreditClient(api_key="your_api_key")
account = await client.accounts.me()
print(f"Account: {account.wallet_address}")
await client.close()
asyncio.run(main())
Error Handling
from crowd_credit.exceptions import CrowdCreditError, RateLimitError
try:
client.credit.draw(amount="1000")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")
except CrowdCreditError as e:
print(f"API error: {e.code} - {e.message}")