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

You can install the package directly from PyPI:

pip install openpond-sdk

Or install from source:

git clone https://github.com/duckailabs/python-openpond-sdk.git
cd python-openpond-sdk
pip install -e .

Usage

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

from openpond import OpenPondSDK, OpenPondConfig

# Initialize the SDK
config = OpenPondConfig(
    api_url="API_URL",
    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.2.0.tar.gz (4.7 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.2.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openpond_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 4.7 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.2.0.tar.gz
Algorithm Hash digest
SHA256 466e0a35ff79b6efe721348f3fff7f0ab0a117c2a2c3258d761c6caafd0fb074
MD5 a69c15dd68909dc8e7f4789ea7afc139
BLAKE2b-256 069d15ad17be1c132414f8ca0eececd25fe7250b792b5054320fdd20f873c932

See more details on using hashes here.

File details

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

File metadata

  • Download URL: openpond_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d8984c6d69829b8317618dc8b6a5e1ee2977966a75e6a16de164028e23595e7
MD5 29beea23f27125713448a445223e90d4
BLAKE2b-256 b86b30dad3de1d8561d9713378050e027dd4db2de552482ff66fd620e66e45fd

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