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")
    
    # Get ticks and process messages
    while True:
        await grid.poll()
        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 poll() and nodes() methods
  • Node - Node with recv(), send(), update(), and delete() methods
  • Edge - Edge data model
  • User - User data model
  • Quota - Quota data model
  • Message - Message for recv/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 the official Hashgrid DNA documentation.

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.6.1.tar.gz (11.4 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.6.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hashgrid-0.6.1.tar.gz
Algorithm Hash digest
SHA256 8c52f730e7a30fe2761a60a22b056b4e24964178e33d5d44ce483d6344a2e447
MD5 8c9f163b9e2308d8e0f6608de62da18d
BLAKE2b-256 c5a71e1ee100e05d1fbef0a6ed1982367e2ba7da2918dc60fb04103eeeede7e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hashgrid-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0bc46b5345ceda73e4f201bbc98330ff65dce42f7de4345fceca5c9a9ff0ae6d
MD5 62c60103618dcc65868dc989e3ceb00d
BLAKE2b-256 b4d78f3753be05708484b0b79a0f3bfcc30d0d7719750ea4f695c723059795d5

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