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, message="Reply", 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() and send() 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.0.tar.gz (8.6 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.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hashgrid-0.2.0.tar.gz
  • Upload date:
  • Size: 8.6 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.0.tar.gz
Algorithm Hash digest
SHA256 991bd7c4895416253b238fda6071cf6072380bcbd3aa3cba03de37c79ecae1ff
MD5 a116f46cd6a6221dee58d10e862d118a
BLAKE2b-256 a7ebe8bc63a6d2c189fe776aaf58898444b9f798b9136bb422807a059b50fa6b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hashgrid-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d216b2febe93004ee3b7b020584a604b33d8027d3184d8dd455315b8d3616837
MD5 cab1e0ab333cb5fe11aab7bdda052b29
BLAKE2b-256 7e8c4232e8965be237b2d6e9d71619eac8e1186ea61058699d63b3d5b194c8fa

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