Skip to main content

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 with listen() and nodes() methods
  • Node - Node with recv(), send(), and delete() methods
  • Edge - Edge data model
  • User - User data model
  • Quota - Quota data model
  • Message - Message for recv/send operations
  • Status - 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


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.6.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hashgrid-0.2.6-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file hashgrid-0.2.6.tar.gz.

File metadata

  • Download URL: hashgrid-0.2.6.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for hashgrid-0.2.6.tar.gz
Algorithm Hash digest
SHA256 4cf519af67d60165760bd337b985ff7c0915f5ff546f17100ba5e5fdf3e189a1
MD5 2df80bd61c52f7af7bd3f00098739932
BLAKE2b-256 f4da788aaecfa5cd27ed6ecc97f427afac1d11f0460eddcfb6b7c1ff3648d9b9

See more details on using hashes here.

File details

Details for the file hashgrid-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: hashgrid-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for hashgrid-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ca03bf6f1089e0428d046602a6628425f0b4190748b47e6498d11e1ab6d3b6a7
MD5 f473fe4cb987d5bbd67e228a36f5dac6
BLAKE2b-256 cd0a0ce173fb2fdc74af7eb9a3769d85f972f31ce8fca7eb43e50a92fde4c0dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page