Python SDK for the Agent Network System (ANS)
Project description
ANS Python SDK
Python SDK for interacting with the Agent Network System (ANS).
Installation
Install from PyPI:
pip install ans-project-sdk
Usage
ANSClient
The main entry point for the SDK is the ANSClient class.
from ans_project.sdk import ANSClient
client = ANSClient() # Defaults to public ANS endpoint
# Generate a new key pair
public_key, private_key = ANSClient.generate_key_pair()
# Register an agent
agent_data = {
"agent_id": "my-python-agent.ans",
"name": "My Python Agent",
"capabilities": ["python_sdk_test"],
"public_key": public_key
}
try:
response = client.register(agent_data, private_key)
print("Registration successful:", response)
except Exception as e:
print("Registration failed:", e)
# Lookup an agent
try:
response = client.lookup({"agent_id": "my-python-agent.ans"})
print("Lookup successful:", response)
except Exception as e:
print("Lookup failed:", e)
anslookup CLI
The SDK includes a command-line interface tool, anslookup, for quickly querying the Agent Network System.
To use it, ensure the SDK is installed (e.g., pip install ans-project-sdk)
# Get help and see all options
anslookup --help
# Lookup an agent by its ID
anslookup my-python-agent.ans
# Lookup agents by name and trust level
anslookup --query "Nexus Voyager" --trust-level "provisional"
# Lookup agents by capabilities (use quotes for capabilities with spaces)
anslookup --capabilities "discovery,learning"
Payload Validation
The SDK uses Pydantic to perform client-side validation on the register method's payload. This ensures that the data conforms to the ANS backend schema before it is sent, providing fast and clear error messages.
For example, if you try to register an agent without the required name field:
# Invalid payload (missing 'name')
invalid_agent_data = {
"agent_id": "invalid-agent.ans",
"public_key": public_key
}
try:
client.register(invalid_agent_data, private_key)
except ValueError as e:
print(f"Validation failed as expected: {e}")
This will immediately raise a ValueError with a detailed message about the missing field, preventing an unnecessary API call.
Key Management
The generate_key_pair method returns a new public/private key pair in PEM format. The private key must be stored securely and should not be checked into version control.
For production applications, use a secure secret management system like Google Secret Manager.
Changelog
0.0.5 (2025-09-14)
- Fixed: Resolved
ModuleNotFoundErrorwhen importingans_project.sdkafterpip install. The package structure has been corrected to ensureans_projectis a top-level importable module.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ans_project_sdk-0.0.6.tar.gz.
File metadata
- Download URL: ans_project_sdk-0.0.6.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd504d4e8575bba01d52d5019703b717bc7f6834b12f5694a83c30f580217c72
|
|
| MD5 |
59b3cdcb44687309cfee1aab1dcc5d17
|
|
| BLAKE2b-256 |
04549422e424303abdfcd1a82a02ba188ea8f4522b1b268b1d780f0f75a182a7
|
File details
Details for the file ans_project_sdk-0.0.6-py3-none-any.whl.
File metadata
- Download URL: ans_project_sdk-0.0.6-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb359b92bd629dcb506489354d343e10392f4d5446a8ee96cdbc7ebf8e212bb6
|
|
| MD5 |
333ef4af0a82b56ca3628ef65a1f88b9
|
|
| BLAKE2b-256 |
5b4ccc306aeaf1bc07571680b04ea8fd433b156b1577733eacb10e02c2aeb17b
|