Skip to content
/ cnstr.py Public

The official library for interacting with Canister in Python.

License

Notifications You must be signed in to change notification settings

cnstr/cnstr.py

Repository files navigation

cnstr.py

Downloads License

The official library to interact with the Canister API in Python!
For more information about Canister, see our website and documentation

Installation

The library is available as a wheel from PyPi and can be installed using pip

pip install -U cnstr

Documentation

See here for all cnstr.py documentation.

Example Usage

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')))

Contributing

See here for instructions on how to contribute.

About

The official library for interacting with Canister in Python.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages