Python SDK
Installation
pip install crowdproof
Requires Python 3.8+.
Initialization
from crowdproof import CrowdProofClient
client = CrowdProofClient(api_key="cp_live_abc123...")
Reputation Scores
# Single score
score = client.get_score("0x1234...", "DEFI_LENDING")
print(f"Score: {score.score}, Tier: {score.tier}")
# All categories
all_scores = client.get_all_scores("0x1234...")
for s in all_scores.scores:
print(f"{s.category}: {s.score}")
# Batch query
batch = client.batch_query(
addresses=["0x1234...", "0x5678..."],
category="DEFI_LENDING"
)
ZK Proofs
# Generate proof
proof = client.generate_proof(
subject="0x1234...",
proof_type="ScoreAboveThreshold",
category="DEFI_LENDING",
threshold=700
)
# Verify
result = client.verify_proof(proof.proof)
print(f"Valid: {result.valid}")
Identity (DID)
# Register
did = client.register_did("0x1234...", chain_id=1)
# Resolve
resolved = client.get_did("did:ethr:0x1234...")
# Issue credential
cred = client.issue_credential(
did="did:ethr:0x1234...",
credential_type="KYCVerification",
subject='{"level": "enhanced"}'
)
Compliance
# Age verification (ZK-based)
result = client.verify_age("0x1234...", minimum_age=21)
print(f"Verified: {result.verified}")
# Sanctions check
check = client.sanctions_check("0x1234...")
print(f"Sanctioned: {check.sanctioned}")
Error Handling
from crowdproof import CrowdProofError
try:
score = client.get_score("invalid", "DEFI_LENDING")
except CrowdProofError as e:
print(f"Error {e.status}: {e.message}")
if e.status == 429:
time.sleep(e.retry_after)
Async Support
from crowdproof import AsyncCrowdProofClient
async def main():
client = AsyncCrowdProofClient(api_key="cp_live_abc123...")
score = await client.get_score("0x1234...", "DEFI_LENDING")
print(score.score)