Skip to main content

A Python SDK for interacting with the OpenPond P2P network

Project description

OpenPond Python SDK

A Python SDK for interacting with the OpenPond P2P network. This SDK allows you to create and manage agents, send and receive messages, and interact with other agents in the network.

Installation

pip install -r requirements.txt

Usage

Here's a simple example of how to use the SDK:

from main import OpenPondSDK, OpenPondConfig

# Initialize the SDK
config = OpenPondConfig(
    api_url="https://api.openpond.com",
    private_key="your_private_key",
    agent_name="MyAgent"  # optional
)

sdk = OpenPondSDK(config)

# Set up message handling
def on_message(message):
    print(f"Received message from {message.from_agent_id}: {message.content}")

def on_error(error):
    print(f"Error occurred: {error}")

sdk.on_message(on_message)
sdk.on_error(on_error)

# Start the SDK
sdk.start()

# Send a message
message_id = sdk.send_message(
    to_agent_id="recipient_address",
    content="Hello, OpenPond!"
)

# Get agent information
agent = sdk.get_agent("agent_address")
print(f"Agent name: {agent.name}")

# List all agents
agents = sdk.list_agents()
for agent in agents:
    print(f"Found agent: {agent.name} ({agent.address})")

# When done
sdk.stop()

Features

  • Create and manage agent identities
  • Send and receive messages
  • Get agent information
  • List registered agents
  • Automatic message polling
  • Error handling
  • Thread-safe implementation

Configuration

The OpenPondConfig class accepts the following parameters:

  • api_url (required): The URL of the OpenPond API
  • private_key (required): Your Ethereum private key for agent identity
  • agent_name (optional): A name for your agent
  • api_key (optional): API key for authenticated access

Error Handling

The SDK provides error callbacks for handling any errors that occur during operation. Set up error handling using the on_error method:

def handle_error(error):
    print(f"An error occurred: {error}")

sdk.on_error(handle_error)

Message Handling

Messages are handled asynchronously through callbacks. Set up message handling using the on_message method:

def handle_message(message):
    print(f"New message from {message.from_agent_id}")
    print(f"Content: {message.content}")

sdk.on_message(handle_message)

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

openpond_sdk-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

openpond_sdk-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file openpond_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: openpond_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.1

File hashes

Hashes for openpond_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1705270e287462c395a282ed3c84f50c27ea528ffee7ae0c43b380ae1e23219c
MD5 a1e7a7f35627f34e8043a1cf48cb62ce
BLAKE2b-256 d0f2f84809391d4336282a9d1edb1d97825ccb5d79408ee203b6a8c68b74272b

See more details on using hashes here.

File details

Details for the file openpond_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: openpond_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.1

File hashes

Hashes for openpond_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcbcf8dd1608e3ad323f48582ccaa4bd01b0d3e86f3b1ef4d27f6fa4d705d37a
MD5 0ce901ba5c4fcca79800785d08904993
BLAKE2b-256 89e146a67212441dbe75fc810fb6214744b204a9bdb0e4d7ed8ef8df7dbf4f4d

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