Skip to content

bk62/polygon-scan-python

Repository files navigation

Contributors Forks Stargazers Issues MIT License


polygon-scan-python

An API client for Polygon Scan written in python
Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. References

About The Project

An API client library for Polygon Scan written in Python 3

WIP

(back to top)

Built With

(back to top)

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

Install poetry as in https://python-poetry.org/docs/

Installation

  1. Clone the repo
git clone https://github.com/bk62/polygon-scan-python.git
  1. Install required python packages with poetry
cd polygon-scan-python
poetry install
  1. (Optional) Get a free API Key at https://polygonscan.com
  2. (Optional) Enter your API KEY in an .env file
echo "export POLYGON_SCAN_API_KEY=<YOUR_API_KEY>" > .env;

(back to top)

Usage

from polygon_scan import PolygonScan

address = "0x157B46dF4457ee4aca3137950a2E412EF368C58B"

pg_scan = PolygonScan()

balance = pg_scan.account.get_account_balance(address)
print(f"{address} balance: {balance}")

txns = pg_scan.account.get_account_normal_transactions(address)
for txn in txns[:5]:
  print(txn)

(back to top)

Roadmap

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

This project uses Betamax to mock requests by recording actual HTTP responses. The default record mode "once", raises exceptions when it encounters a new request. The first time you add a test for a new API call method:

  1. Export POLYGON_SCAN_API_KEY from a .env file (refer to .env.example)
  2. Run the run_tests.sh -k <your_test_name> script which forces Betamax to re-record ALL selected response fixtures using the API key (by temporarily setting betamax record mode to "all").
  • The script sets a 2 sec delay between requests to safely respect rate limits.
  • Any arguments are passed to pytest

Simply run poetry pytest to run all tests using existing fixtures.

Delete the relevant fixture file tests/fixtures/cassettes/test.<test_module_name>.<test_name> and rerun run_tests.sh if necessary.

(back to top)

License

MIT

(back to top)

Contact

@bk_862

Project Link: https://github.com/bk62/polygon-scan-python

(back to top)

References

PolygonScan docs

HTTP client implementation significantly influenced by prawcore

(back to top)

About

An API client library for Polygon Scan written in Python 3 WIP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published