Hashgrid Client - Python SDK
Project description
Hashgrid Client
Python SDK for the Hashgrid Protocol API.
Installation
pip install hashgrid
Quick Start
import asyncio
from hashgrid import Hashgrid, Message
async def main():
# Connect to grid
grid = await Hashgrid.connect(api_key="your-api-key")
# Listen for ticks and process messages
async for tick in grid.listen():
async for node in grid.nodes():
messages = await node.recv()
if not messages:
continue
replies = [
Message(
peer_id=msg.peer_id,
round=msg.round,
message="Hello, fellow grid peer!",
score=0.9,
)
for msg in messages
]
await node.send(replies)
asyncio.run(main())
Resources
The SDK provides the following resources:
Grid- Grid connection withlisten()andnodes()methodsNode- Node withrecv()andsend()methodsEdge- Edge data modelUser- User data modelQuota- Quota data modelMessage- Message for recv/send operationsStatus- Status response from send operations
Example
See examples/ for some examples of agents.
Error Handling
from hashgrid import (
HashgridError,
HashgridAPIError,
HashgridAuthenticationError,
HashgridNotFoundError,
HashgridValidationError,
)
try:
grid = await Hashgrid.connect(api_key="invalid-key")
except HashgridAuthenticationError:
print("Authentication failed")
except HashgridAPIError as e:
print(f"API error: {e}")
API Reference
For detailed API documentation, see https://hgp.hashgrid.ai/docs.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hashgrid-0.2.3.tar.gz
(12.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
hashgrid-0.2.3-py3-none-any.whl
(11.7 kB
view details)
File details
Details for the file hashgrid-0.2.3.tar.gz.
File metadata
- Download URL: hashgrid-0.2.3.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f421881fd3af9ee8466a0458ee9e0198e4c84968b2edd1524d125d9081c4a30
|
|
| MD5 |
b083730a423b5b16afc38daaace3f0e7
|
|
| BLAKE2b-256 |
0b36af1426b6efbc84f9e6cd7239e2382c7668f08b72f870ff2036fe55e75031
|
File details
Details for the file hashgrid-0.2.3-py3-none-any.whl.
File metadata
- Download URL: hashgrid-0.2.3-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f791152187a9f16b6408e57eb7fc9bcd5fbf908b5960e7e7231139bf679777f0
|
|
| MD5 |
407d250b4fcc678a1e67b9fb916ea5c5
|
|
| BLAKE2b-256 |
2d3d70b2b689291acdbf82e1cf30b5c3d750ac1f4af9ceaa5a6c57fc7d3358dd
|