{"id":15470069,"url":"https://github.com/tarsil/polygonscan-python","last_synced_at":"2025-08-19T21:31:28.024Z","repository":{"id":46779754,"uuid":"408262063","full_name":"tarsil/polygonscan-python","owner":"tarsil","description":"The Polygon Scan APIs for python based from the fork of bscscan-python","archived":false,"fork":false,"pushed_at":"2024-06-23T11:32:55.000Z","size":423,"stargazers_count":23,"open_issues_count":3,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-19T00:37:43.983Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tarsil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["tarsil"]}},"created_at":"2021-09-19T23:44:42.000Z","updated_at":"2024-08-09T04:23:29.000Z","dependencies_parsed_at":"2024-10-31T18:04:32.457Z","dependency_job_id":"7d2be380-c3be-4b90-bacb-e25287efd3d2","html_url":"https://github.com/tarsil/polygonscan-python","commit_stats":{"total_commits":8,"total_committers":4,"mean_commits":2.0,"dds":0.625,"last_synced_commit":"9de6b1378b07ce82dd298291e4a324ab0f560eab"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarsil%2Fpolygonscan-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarsil%2Fpolygonscan-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarsil%2Fpolygonscan-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarsil%2Fpolygonscan-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarsil","download_url":"https://codeload.github.com/tarsil/polygonscan-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230367928,"owners_count":18215338,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T02:02:08.875Z","updated_at":"2024-12-19T03:08:21.170Z","avatar_url":"https://github.com/tarsil.png","language":"Python","funding_links":["https://github.com/sponsors/tarsil"],"categories":[],"sub_categories":[],"readme":"# polygonscan-python\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/tarsil/polygonscan-python\" alt=\"build\"\u003e\n        \u003cimg src=\"https://github.com/tarsil/polygonscan-python/workflows/build/badge.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://badge.fury.io/py/polygonscan-python\" alt=\"pypi\"\u003e\n        \u003cimg src=\"https://badge.fury.io/py/polygonscan-python.svg\" /\u003e\u003c/a\u003e\n  \n  \u003ca href=\"\" alt=\"license\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/tarsil/polygonscan-python\" /\u003e\u003c/a\u003e\n  \n  \u003ca href=\"https://www.python.org/downloads/release/python-385/\" alt=\"python-version\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/python-3.8-blue.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  A complete Python API for \u003ca href=\"https://polygonscan.com/\"\u003ePolygonScan.com\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  Powered by \u003ca href=\"https://polygonscan.com/apis\"\u003ePolygonScan.com APIs\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  Available on \u003ca href=\"https://pypi.org/project/polygonscan-python/\"\u003ePyPI\u003c/a\u003e \n\u003c/p\u003e\n\n\n\u003cp align=\"center\"\u003e\n  \u003ci\u003eA fork of the \u003ca href=\"https://github.com/pcko1/bscscan-python\"\u003ebscscan-python\u003c/a\u003e package.\u003c/i\u003e\n\u003c/p\u003e\n\nA minimal, yet complete, Python API for [polygonscan.com](https://polygonscan.com/).\n\nThis package was based on [bscscan-python](https://github.com/pcko1/bscscan-python) and\napplied to the polygon network. A special thanks to the [creator](https://github.com/pcko1).\n\nAvailable on [PyPI](https://pypi.org/project/polygonscan-python/). Powered by [polygonscan.com APIs](https://polygonscan.com/apis#misc).\n\n___\n\n## Endpoints\n\nThe following endpoints are provided:\n\n\u003cdetails\u003e\u003csummary\u003eAccounts \u003ca href=\"https://polygonscan.com/apis#accounts\"\u003e(source)\u003c/a\u003e\u003c/summary\u003e\n\u003cp\u003e\n\n* `get_matic_balance`\n* `get_matic_balance_multiple`\n* `get_normal_txs_by_address`\n* `get_normal_txs_by_address_paginated`\n* `get_internal_txs_by_address`\n* `get_internal_txs_by_address_paginated`\n* `get_internal_txs_by_txhash`\n* `get_internal_txs_by_block_range_paginated`\n* `get_erc20_token_transfer_events_by_address`\n* `get_erc20_token_transfer_events_by_contract_address_paginated`\n* `get_erc20_token_transfer_events_by_address_and_contract_paginated`\n* `get_erc721_token_transfer_events_by_address`\n* `get_erc721_token_transfer_events_by_contract_address_paginated`\n* `get_erc721_token_transfer_events_by_address_and_contract_paginated`\n* `get_mined_blocks_by_address`\n* `get_mined_blocks_by_address_paginated`\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eContracts \u003ca href=\"https://polygonscan.com/apis#contracts\"\u003e(source)\u003c/a\u003e\u003c/summary\u003e\n\u003cp\u003e\n  \n* `get_contract_abi`\n* `get_contract_source_code`\n\n\u003c/details\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eTransactions \u003ca href=\"https://polygonscan.com/apis#transactions\"\u003e(source)\u003c/a\u003e\u003c/summary\u003e\n\u003cp\u003e\n  \n* `get_contract_execution_status`\n* `get_tx_receipt_status`\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eBlocks \u003ca href=\"https://polygonscan.com/apis#blocks\"\u003e(source)\u003c/a\u003e\u003c/summary\u003e\n\u003cp\u003e\n  \n* `get_block_reward_by_block_number`\n* `get_est_block_countdown_time_by_block_number`\n* `get_block_number_by_timestamp`\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eGETH/Parity Proxy \u003ca href=\"https://polygonscan.com/apis#proxy\"\u003e(source)\u003c/a\u003e\u003c/summary\u003e\n\u003cp\u003e\n\n* `get_proxy_block_number`\n* `get_proxy_block_by_number`\n* `get_proxy_uncle_by_block_number_and_index`\n* `get_proxy_block_transaction_count_by_number`\n* `get_proxy_transaction_by_hash`\n* `get_proxy_transaction_by_block_number_and_index`\n* `get_proxy_transaction_count`\n* `get_proxy_transaction_receipt`\n* `get_proxy_call`\n* `get_proxy_code_at`\n* `get_proxy_storage_position_at`\n* `get_proxy_gas_price`\n* `get_proxy_est_gas`\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eTokens \u003ca href=\"https://polygonscan.com/apis#tokens\"\u003e(source)\u003c/a\u003e\u003c/summary\u003e\n\u003cp\u003e\n  \n* `get_total_supply_by_contract_address`\n* `get_acc_balance_by_token_and_contract_address`\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eGas Tracker \u003ca href=\"https://polygonscan.com/apis#gastracker\"\u003e(source)\u003c/a\u003e\u003c/summary\u003e\n\u003cp\u003e\n  \n* `get_est_confirmation_time`\n* `get_gas_oracle`\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eStats \u003ca href=\"https://polygonscan.com/apis#stats\"\u003e(source)\u003c/a\u003e\u003c/summary\u003e\n\u003cp\u003e\n  \n* `get_total_matic_supply`\n* `get_matic_last_price`\n\n\u003c/details\u003e\n\n*If you think that a newly-added method is missing, kindly open an [issue](https://github.com/tarsil/polygonscan-python/issues) as a feature request and I will do my best to add it.*\n\n## Installation\n\nBefore proceeding, you should register an account on [polygonscan.com](https://polygonscan.com/)\nand [generate a personal API key](https://polygonscan.com/myapikey) to use.\n\nIf you wish to have access to the PRO endpoints, you should obtain elevated privileges via PolygonScans's\nsubscription service.\n\nInstall from source:\n\n``` bash\npip install git+https://github.com/tarsil/polygonscan-python\n```\n\nAlternatively, install from [PyPI](https://pypi.org/project/polygonscan-python/):\n\n```bash\npip install polygonscan-python\n```\n\n## Unit tests\n\nIn `bash`, test that everything looks OK on your end using your `YOUR_API_KEY` (without quotation marks)\nbefore proceeding:\n\n``` bash\nbash run_tests.sh YOUR_API_KEY\n````\n\nThis will regenerate the logs under `logs/` with the most recent results and the timestamp of the execution.\n\n## Usage\n\nIn `python`, create a client with your personal [polygonscan.com](https://polygonscan.com/) API key:\n\nE.g:\n``` python\nfrom polygonscan import PolygonScan\n\nwith PolygonScan(\"API_KEY\",False) as matic:\n    print(matic.get_matic_balance(address=\"0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a\"))\n```\n\nThen you can call all available methods, e.g.:\n\n``` python\nmatic.get_matic_balance(address=\"0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a\")\n\n\u003e '40891631566070000000000'\n```\nYou can also choose one of the other testnets:\n``` python\nmatic = PolygonScan(YOUR_API_KEY, net=\"ropsten\") # net name is case-insensitive, default is main\n```\n\n## Examples\n\nExamples (arguments and results) for all methods may be found as JSON files\n[here](https://github.com/tarsil/polygonscan-python/tree/master/logs).\nFor example, if you want to use the method `get_block_number_by_timestamp`,\nyou can find the supported arguments and the format of its output in its respective \n[JSON file](logs/standard/get_block_number_by_timestamp.json):\n\n``` json\n{\n  \"method\": \"get_block_number_by_timestamp\",\n  \"module\": \"blocks\",\n  \"kwargs\": {\n    \"timestamp\": \"1578638524\",\n    \"closest\": \"before\"\n  },\n  \"log_timestamp\": \"2020-10-28-12:34:44\",\n  \"res\": \"9251482\"\n}\n```\n\nwhere `kwargs` refer to the required named arguments and `res` refers to the expected result if you were to run:\n\n``` python\neth.get_block_number_by_timestamp(timestamp=\"1578638524\", closest=\"before\")\n\n\u003e '9251482'\n```\n\n**Disclaimer**: Those examples blindly use the arguments originally showcased\n[here](https://api.polygonscan.com/apis) and the selected wallets/contracts\ndo not reflect any personal preference. You should refer to the same source for additional\ninformation regarding specific argument values.\n\n## Issues\n\nFor problems regarding installing or using the package please open an\n[issue](https://github.com/tarsil/polygonscan-python/issues).\nKindly avoid disclosing potentially sensitive information such as your API keys or your wallet addresses.\n\nFeel free to leave a :star: if you found this package useful.\n\n___\n\n Powered by [polygonscan.com APIs](https://polygonscan.com/apis).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarsil%2Fpolygonscan-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarsil%2Fpolygonscan-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarsil%2Fpolygonscan-python/lists"}