Package: hydrachain-explorer-requester
Hydrachain Explorer RequesterEasy to use library for accessing theHydrachain Explorerendpoints.InstallationPyPI:pip install hydrachain-explorer-requesterLocal:Download thelatest releaseand run the below command to install it globally:pip install .ExamplesBlock:fromhydrachain_explorer_requester.explorer_requesterimportExplorerRequesterexplorer_requester=ExplorerRequester()# Block - https://explorer.hydrachain.org/block/123/block_response=explorer_requester.get_block(123)print(block_response)Address Transactions:fromhydrachain_explorer_requester.explorer_requesterimportExplorerRequesterexplorer_requester=ExplorerRequester()# Address - https://explorer.hydrachain.org/address/HCiMdPYCsdPPvbjxHQMmK8QVBEGwextvir/address_transactions=explorer_requester.get_address_transactions("HCiMdPYCsdPPvbjxHQMmK8QVBEGwextvir")print(address_transactions)Address Transactions - Query Parameters:fromhydrachain_explorer_requester.explorer_requesterimportExplorerRequesterexplorer_requester=ExplorerRequester()# Address - https://explorer.hydrachain.org/address/HCiMdPYCsdPPvbjxHQMmK8QVBEGwextvir/query_parameters=TransactionsQueryParameters()query_parameters.set_page(0)query_parameters.set_page_size(3)query_parameters.set_from(555555)query_parameters.set_to_block(666666)address_transactions=explorer_requester.get_address_transactions("HCiMdPYCsdPPvbjxHQMmK8QVBEGwextvir",query_parameters)print(address_transactions)Search:fromhydrachain_explorer_requester.explorer_requesterimportExplorerRequesterdefsearch(value:str)->dict:search_response=explorer_requester.search(value)if'type'notinsearch_response:return{}type=search_response['type']matchtype:case'block':returnexplorer_requester.get_block(int(value))case'transaction':returnexplorer_requester.get_transaction(value)case'address':returnexplorer_requester.get_address(value)case'contract':address=search_response['address']returnexplorer_requester.get_contract(address)case_:print(f'Type{type}not implemented!')return{}explorer_requester=ExplorerRequester()# Block - https://explorer.hydrachain.org/block/1234print(search('1234'))# Transaction - https://explorer.hydrachain.org/tx/23ebd8cb30e701b1dce693bb427092dcbf7091dd5cb263d9962b9245a38662f6print(search('23ebd8cb30e701b1dce693bb427092dcbf7091dd5cb263d9962b9245a38662f6'))# Address - https://explorer.hydrachain.org/address/H7FYCLijimtbYk7gdN1hmweftuWLQni3m5print(search('H7FYCLijimtbYk7gdN1hmweftuWLQni3m5'))# Contract/Token - https://explorer.hydrachain.org/contract/4ab26aaa1803daa638910d71075c06386e391147print(search('LockTrip'))Why we didn't implement the search?Because the idea of the library is provide you with the raw responses, without any modification.Configuration: (Optional)importloggingimportrequestsfromrequests.adaptersimportHTTPAdapterimporthydrachain_explorer_requesterfromhydrachain_explorer_requester.explorer_requesterimportExplorerRequesterlogging.basicConfig(level=logging.DEBUG)logger=logging.getLogger(__name__)#Configure the used requesterhttp_adapter=HTTPAdapter(pool_connections=requests.adapters.DEFAULT_POOLSIZE,pool_maxsize=requests.adapters.DEFAULT_POOLSIZE,max_retries=3,pool_block=requests.adapters.DEFAULT_POOLBLOCK,)#Place the configured requester configurationexplorer_requester=ExplorerRequester(timeout_seconds=0.5,# 500 millisecondshttp_adapter=http_adapter)# Configure the level of logging.hydrachain_explorer_requester.explorer_requester._logger.setLevel(logging.INFO)block=explorer_requester.get_block(1234)logger.info(block)Functionalities:All of the explorer requests are supportedYou can configure the used requester in the library using thetimeout_secondsandhttp_adapter. Specifyhooksif you want via hooks and also configure thelogger.You can overwrite specific explorer URL. Examples present under/examplesYou can overwrite  a query parameter. Examples present under/examplesVersionsThis library supportsPython 3.11+.hydrachain-explorer-requesteruses a modified version ofSemantic Versioningfor all changes to the helper library. It is strongly encouraged that you pin at least the major version and potentially the minor version to avoid pulling in breaking changes.Semantic Versions take the form ofMAJOR.MINOR.PATCHWhen bugs are fixed in the library in a backwards-compatible way, thePATCHlevel will be incremented by one. When new features are added to the library in a backwards-compatible way, thePATCHlevel will be incremented by one.PATCHchanges shouldnotbreak your code and are generally safe for upgrade.When a new large feature set comes online or a small breaking change is introduced, theMINORversion will be incremented by one and thePATCHversion reset to zero.MINORchangesmayrequire some amount of manual code change for upgrade. These backwards-incompatible changes will generally be limited to a small number of function signature changes.TheMAJORversion is used to indicate the family of technology represented by the helper library. Breaking changes that require extensive reworking of code will cause theMAJORversion to be incremented by one, and theMINORandPATCHversions will be reset to zero. We understand that this can be very disruptive, so we will only introduce this type of breaking change when absolutely necessary. NewMAJORversions will be communicated in advance withRelease Candidatesand a schedule.Only the currentMAJORversion ofhydrachain-explorer-requesteris supported. New features, functionality, bug fixes, and security updates will only be added to the currentMAJORversion.