RFG: Improve Python API

This is a ask Request-For-Grant to clean up Python APIs for NEAR.

We currently don’t have Borsh Python library.
There is some aspects of it implemented in a very under-developed library - https://github.com/near/near-api-py
Also a lot of python scripts that should be using Python API - are not currently - https://github.com/near/nearcore/tree/master/pytest

The goal would be to make this on the level that we have JS:

  • borsh-py - Borsh serialization/deserialization library with decorators for classes in Python.
  • near-api-py - full featured for backend development, has good test coverage and CI, has basic documentation (added to docs.near.org) and is published to PIP.
  • https://github.com/near/nearcore/tree/master/pytest refactored to use near-api-py
3 Likes

I’ve started to work on this in my spare time. I’ve started from borsh-py. I’ve frozen borsh package on PyPi https://pypi.org/project/borsh/. Anyway I’m going to transfer the ownership of PyPi package to some NEAR account when I finish.

1 Like

Hey, just posting to say I’ve submitted a grant request to make borsh-py happen. I already know how to do it by building on top of the construct library, which is the best way to do this in Python, and which I know in great depth.

borsh-py will also cover things that are hard to represent in Python, like Rust’s enums (very different from Python enums).

I agree, the near-api-py library could really use some TLC.

Specifically it would be amazing, and some work, to bring it up to par with, for example, Solana’s python libs (anchorpy and solana-py).

I’m very familiar with these two solana libs and willing to port features over to NEAR. Is this something NEAR would be able to support through a grant?