{"openapi":"3.1.0","info":{"title":"ContractABI API","description":"Free REST API for smart contract ABIs across all EVM chains. Fetch ABIs, search contracts, decode calldata, and explore contract relationships.","version":"2.1.0","contact":{"name":"B3 Team","email":"support@b3.fun","url":"https://b3.fun"},"license":{"name":"MIT"}},"servers":[{"url":"https://contractabi.com","description":"Production"}],"paths":{"/health":{"get":{"operationId":"healthCheck","summary":"Health check","description":"Returns the health status of the API.","responses":{"200":{"description":"API is healthy","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"healthy"},"timestamp":{"type":"string","format":"date-time"}}}}}}}}},"/stats":{"get":{"operationId":"getStats","summary":"Get API statistics","description":"Returns aggregate statistics about the indexed contract database.","responses":{"200":{"description":"Statistics","content":{"application/json":{"schema":{"type":"object","properties":{"contracts":{"type":"object","properties":{"total":{"type":"integer","example":12345},"withNameTags":{"type":"integer","example":8901}}},"chainsSupported":{"type":"integer","example":15}}}}}}}}},"/{chainId}/{address}":{"get":{"operationId":"getContractABI","summary":"Get contract ABI","description":"Fetch the ABI for a smart contract on any EVM chain.","parameters":[{"name":"chainId","in":"path","required":true,"schema":{"type":"integer"},"description":"EVM chain ID (e.g., 1 for Ethereum, 137 for Polygon)","examples":{"ethereum":{"value":1,"summary":"Ethereum Mainnet"},"base":{"value":8453,"summary":"Base"},"polygon":{"value":137,"summary":"Polygon"}}},{"name":"address","in":"path","required":true,"schema":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"},"description":"Contract address (0x-prefixed, 40 hex characters)","example":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"}],"responses":{"200":{"description":"Contract ABI found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractABIResponse"}}}},"404":{"description":"Contract not found or not verified","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/search":{"get":{"operationId":"searchContracts","summary":"Search contracts","description":"Search indexed contracts by name, tag, or address.","parameters":[{"name":"q","in":"query","schema":{"type":"string"},"description":"Search query","example":"uniswap"},{"name":"chainId","in":"query","schema":{"type":"integer"},"description":"Filter by chain ID"},{"name":"page","in":"query","schema":{"type":"integer","default":1},"description":"Page number"},{"name":"limit","in":"query","schema":{"type":"integer","default":20,"maximum":100},"description":"Results per page"}],"responses":{"200":{"description":"Search results","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchResponse"}}}}}}},"/list":{"get":{"operationId":"listContracts","summary":"List contracts","description":"List contracts with usage statistics, optionally filtered by chain.","parameters":[{"name":"chainId","in":"query","schema":{"type":"integer"},"description":"Filter by chain ID"},{"name":"page","in":"query","schema":{"type":"integer","default":1},"description":"Page number"},{"name":"limit","in":"query","schema":{"type":"integer","default":20,"maximum":100},"description":"Results per page"},{"name":"sortBy","in":"query","schema":{"type":"string","enum":["tx_30d","users_30d","tx_7d","users_7d"],"default":"tx_30d"},"description":"Sort by metric"}],"responses":{"200":{"description":"Contract list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListResponse"}}}}}}},"/{chainId}/{address}/related":{"get":{"operationId":"getRelatedContracts","summary":"Get related contracts","description":"Get contracts that interact with or are called by the specified contract.","parameters":[{"name":"chainId","in":"path","required":true,"schema":{"type":"integer"}},{"name":"address","in":"path","required":true,"schema":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"}}],"responses":{"200":{"description":"Related contracts data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RelatedContractsResponse"}}}},"202":{"description":"Analysis in progress or triggered"}}}},"/{chainId}/{address}/analyze":{"post":{"operationId":"triggerAnalysis","summary":"Trigger relationship analysis","description":"Trigger a relationship analysis workflow for a contract.","parameters":[{"name":"chainId","in":"path","required":true,"schema":{"type":"integer"}},{"name":"address","in":"path","required":true,"schema":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"}},{"name":"strategy","in":"query","schema":{"type":"string","enum":["dune","explorer","hybrid"],"default":"hybrid"},"description":"Analysis strategy"}],"responses":{"202":{"description":"Analysis workflow started"},"409":{"description":"Analysis already in progress"}}}},"/api/decode":{"post":{"operationId":"decodeCalldata","summary":"Decode transaction calldata","description":"Decode transaction calldata into function signatures.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["calldata"],"properties":{"calldata":{"type":"string","description":"Transaction calldata (hex string)","example":"0xa9059cbb..."},"chainId":{"type":"integer","description":"Chain ID for ABI lookup"},"address":{"type":"string","description":"Contract address for ABI lookup"}}}}}},"responses":{"200":{"description":"Decoded calldata","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"selector":{"type":"string","example":"0xa9059cbb"},"calldata":{"type":"string"},"signatures":{"type":"array","items":{"type":"string"},"example":["transfer(address,uint256)"]},"contract":{"type":"object","properties":{"contractName":{"type":"string"},"nameTag":{"type":"string"},"abi":{"type":"array"}}}}}}}},"400":{"description":"Missing calldata"}}}},"/sync":{"get":{"operationId":"syncTrending","summary":"Sync trending contracts","description":"Manually trigger sync of trending contracts.","responses":{"200":{"description":"Sync initiated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"processed":{"type":"integer"},"queued":{"type":"integer"}}}}}}}}}},"components":{"schemas":{"ContractABIResponse":{"type":"object","properties":{"success":{"type":"boolean"},"chainId":{"type":"integer"},"contractAddress":{"type":"string"},"abi":{"type":"array","description":"Contract ABI as JSON array"},"source":{"type":"string","enum":["database","explorer"]},"contractName":{"type":"string"},"nameTag":{"type":"string"},"explorerUrl":{"type":"string"},"explorerUsed":{"type":"string"},"relatedContracts":{"type":"object","properties":{"totalCalls":{"type":"integer"},"totalCalledBy":{"type":"integer"},"lastAnalyzed":{"type":"string"}}}}},"SearchResponse":{"type":"object","properties":{"success":{"type":"boolean"},"results":{"type":"array"},"total":{"type":"integer"},"page":{"type":"integer"},"limit":{"type":"integer"}}},"ListResponse":{"type":"object","properties":{"success":{"type":"boolean"},"results":{"type":"array"},"total":{"type":"integer"},"page":{"type":"integer"},"limit":{"type":"integer"},"sortBy":{"type":"string"}}},"RelatedContractsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"chainId":{"type":"integer"},"contractAddress":{"type":"string"},"calls":{"type":"array"},"calledBy":{"type":"array"},"totalCalls":{"type":"integer"},"totalCalledBy":{"type":"integer"}}},"ErrorResponse":{"type":"object","properties":{"success":{"type":"boolean","example":false},"error":{"type":"string"}}}}}}