The official library to interact with the Canister API in Python!
For more information about Canister, see our website and documentation
The library is available as a wheel from PyPi and can be installed using pip
pip install -U cnstr
See here for all cnstr.py documentation.
Below is a goood example of how to use cnstr.py
# Imports
import asyncio
from canisterpy import (
Canister,
Package,
PackageSearchFields
)
from typing import List
async def main(package: str) -> List[Package]:
# Setup a client (user agent is always required)
# so that we're capable of monitoring API calls
client = Canister(user_agent='Canister.py Example')
# Create and correctly setup search fields
fields = PackageSearchFields()
fields.set('name', True).set('author', True)
# Search for the given package query
# then, close the Canister client instance
packages = await client.search_package(package, fields)
await client.close()
# Return the results of the Canister query
return packages
print(asyncio.run(main('test')))
See here for instructions on how to contribute.