Python client for querying Top Shot data from Flow API or Cryptoslam.
-
(Optional) create Python virtual environment with
python3 -m venv env. -
Install Python gRPC packages with
pip install -r requirements.txt.
-
Clone Flow repo for protocol buffer source files
git clone [email protected]:onflow/flow.git. -
Compile protocol buffers for Python with
protocwhich is included ingrpcio-tools:-
Download latest platform release (e.g.
protoc-3.15.6-linux-x86_64.zip) from https://github.com/protocolbuffers/protobuf/releases. This containsprotocbinary and Google includes neccessary for compiling. -
Extract
includedirectory from the release and place this in the same directory containingflow/protobuf/flow. -
Create a build directory (e.g.
mkdir build) and compile the protocol buffer source (.protofiles) insideflow/protobuf/flowwithpython -m grpc_tools.protoc -I. --python_out=build/ --grpc_python_out=build/ flow/access/access.proto flow/entities/account.proto flow/entities/block_header.proto flow/entities/block_seal.proto flow/entities/block.proto flow/entities/collection.proto flow/entities/event.proto flow/entities/transaction.proto flow/execution/execution.proto google/protobuf/timestamp.protoThis must be run from the directory containing the build directory and the
flowdirectory which containsaccess,entitiesetc. This command uses theprotocbinary included ingrpcio-tools. Output is saved tobuild. Reference (https://grpc.io/docs/languages/python/quickstart/).
-
Use python3 get_all.py {sales|mints|marketplace} for Cyrptoslam API.