How pcko1/etherscan-python works
Project type and purpose
• This is a Python client library (SDK) wrapping the Etherscan.io REST APIs. It exposes all “standard” and “pro” endpoints for Ethereum mainnet and testnets (Kovan, Rinkeby, Ropsten). It has no UI; it’s intended for other Python code to import and call.
File structure
• Top-level:
• setup.py, MANIFEST.in — packaging
• run_tests.sh — regenerates JSON logs via live API calls
• .github/workflows — CI: build, greetings, publish
• Source package (etherscan/):
• configs/ — per-network JSON files (MAIN, RINKEBY, etc.) hold base URLs & defaults
• enums/ — constants for modules, actions, tags, fields to ensure valid parameters
• modules/ — one Python file per API module (accounts.py, blocks.py, transactions.py, tokens.py, etc.); each defines thin wrappers around endpoints
• etherscan.py — central Etherscan class that
– loads config (network, API key)
– imports enums
– exposes public methods by delegating to module functions
– handles HTTP requests/responses
• utils/ — conversion/parsing helpers for JSON, units, hex
• logs/ — sample JSON responses per method (split in standard/ and pro/), used by tests
• test/ — pytest module(s) that invoke each endpoint and compare against logs
README for additional insights
• Confirms structure: you instantiate Etherscan(YOUR_API_KEY, net="ropsten")
• Enumerates every endpoint by category
• Describes usage of run_tests.sh to refresh logs
Capturing essential details
• Network configs as a distinct block, since the client picks the correct base URL
• Enums as a validation/filtering layer around parameters
• Don’t omit the logs/ → test/ feedback loop; it’s key to quality