Skip to main content

Official Python SDK for the ChainWise DeFi Risk Intelligence API

Project description

chainwise

Official Python SDK for the ChainWise DeFi Risk Intelligence API.

Installation

pip install chainwise

Quick start

from chainwise import ChainWise

client = ChainWise()
result = client.analyze("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", chain="ethereum")

print(result["risk_score"], result["classification"])

Authentication

Most endpoints (analyze, get_cases, get_case, subscribe) are public and require no API key. If your account has API keys enabled for higher rate limits, pass one to the constructor:

client = ChainWise(api_key="your-api-key")

You can also point the client at a different deployment (e.g. a local dev server):

client = ChainWise(base_url="http://localhost:3000")

API reference

analyze(protocol_address, chain="ethereum")

Runs the 8-layer risk analysis on a contract address. chain is one of "ethereum", "polygon", "arbitrum", "optimism", "base".

result = client.analyze("0x...", chain="ethereum")
# {"case_id": ..., "risk_score": ..., "classification": ..., "confidence": ..., "layers": {...}}

get_cases(limit=10, offset=0, chain=None)

Lists published risk case studies as a list of summary dicts. This is the list view — it does not include the full analysis breakdown or HTML report; use get_case(id) for that.

cases = client.get_cases(limit=10, chain="ethereum")

get_case(case_id)

Fetches full details for a single case study, including the 8-layer analysis and HTML report. Raises ChainWiseError with status=404 if the case doesn't exist or isn't published.

detail = client.get_case(2)

subscribe(email, mobile=None)

Subscribes an email to DeFi risk alerts.

result = client.subscribe("you@example.com")

Error handling

All methods raise ChainWiseError on non-2xx responses, carrying the HTTP status and parsed response body:

from chainwise import ChainWise, ChainWiseError

client = ChainWise()
try:
    client.get_case(999999)
except ChainWiseError as err:
    print(err.status, str(err))  # 404 "Case study not found"

Rate limiting

The API enforces a shared rate limit per client IP across all /api/* endpoints. If you exceed it, calls raise ChainWiseError with status=429. Back off and retry after a short delay; the limit resets on a rolling window.

Examples

See examples/ for runnable scripts covering analyze, get_cases, and subscribe.

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

chainwise-1.0.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

chainwise-1.0.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file chainwise-1.0.0.tar.gz.

File metadata

  • Download URL: chainwise-1.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for chainwise-1.0.0.tar.gz
Algorithm Hash digest
SHA256 688cfa6493792a4488b6f45f85f46f8f11890453f417bba1d1869621e7b539b4
MD5 b61ce697c20899371315672b90860c4e
BLAKE2b-256 26716fc1addd5d6c2660c77d622d5fcda10c31faf368245bf0ac69c617f5069b

See more details on using hashes here.

File details

Details for the file chainwise-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: chainwise-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for chainwise-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50fe6ce734f269c9dcf4dc4979bd93bad416f2645e4f43427c460e0fe55e7950
MD5 e24f3be267f66854cf1fefde7fc36882
BLAKE2b-256 d69c35edee80e442ef123465930249c94b60502b9ae0715e6997af366ae4b150

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