https://github.com/cnstr/cnstr.py
The official library for interacting with Canister in Python.
https://github.com/cnstr/cnstr.py
Last synced: about 1 year ago
JSON representation
The official library for interacting with Canister in Python.
- Host: GitHub
- URL: https://github.com/cnstr/cnstr.py
- Owner: cnstr
- License: apache-2.0
- Created: 2021-12-19T22:35:40.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-14T05:26:39.000Z (over 4 years ago)
- Last Synced: 2025-03-28T17:57:20.232Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 81.1 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# cnstr.py
[](https://pypi.org/project/cnstr/)
[](https://github.com/cnstr/cnstr.py/blob/main/LICENSE)
The official library to interact with the Canister API in Python!
For more information about Canister, see our [website](https://canister.me/) and [documentation](https://docs.canister.me/)
### Installation
The library is available as a wheel from [PyPi](https://pypi.org/project/cnstr/) and can be installed using `pip`
```
pip install -U cnstr
```
### Documentation
See [here](./DOCUMENTATION.md) for all cnstr.py documentation.
### Example Usage
Below is a goood example of how to use `cnstr.py`
```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](./CONTRIBUTING.md) for instructions on how to contribute.