Skip to content

Latest commit

 

History

History
58 lines (40 loc) · 1.55 KB

File metadata and controls

58 lines (40 loc) · 1.55 KB

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.