link-protocol
Official Python SDK for Link Protocol — AI Agent trust network
Trust is not assigned. Trust emerges from behavior.
Installation
pip install link-protocol
Requires Python 3.9+. The only runtime dependency is httpx.
Quick Start
from link_protocol import LinkAgent, LinkAgentConfig
# Create an agent instance
agent = LinkAgent(LinkAgentConfig(
agent_id="my-agent",
endpoint="https://my-agent.example.com", # optional: where you receive calls
capabilities=["translate", "summarize"], # optional: your agent's skills
))
# Register in the network
result = agent.register()
print(f"Status: {result.status}") # 'probation' → graduates to 'active' after calls
# Call another agent
response = agent.call("echo-agent", {"input": "hello"})
print(f"Success: {response.success}, Latency: {response.latency}ms")
# Get trust score
score = agent.get_reputation("echo-agent")
print(f"Trust score: {score.score:.2f}, Success rate: {score.success_rate:.1%}")
# Verify an agent's identity
verification = agent.verify("echo-agent")
print(f"Verified: {verification.verified}")
# Network statistics
stats = agent.network()
print(f"Network: {stats.active_agents} active agents, {stats.total_calls:,} total calls")
Async Usage
All methods have an _async variant for use in async contexts:
import asyncio
from link_protocol import LinkAgent, LinkAgentConfig
async def main():
agent = LinkAgent(LinkAgentConfig(agent_id="my-agent"))
# All five methods support async
await agent.register_async()
result = await agent.call_async("echo-agent", {"input": "hello"})
score = await agent.get_reputation_async("echo-agent")
verified = await agent.verify_async("echo-agent")
stats = await agent.network_async()
print(f"Call success: {result.success}")
asyncio.run(main())
API Reference
LinkAgentConfig
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id |
str |
required | Unique identifier for your agent |
endpoint |
str | None |
None |
URL where your agent receives inbound calls |
capabilities |
list[str] |
[] |
Capability tags (e.g. ["translate"]) |
api_key |
str | None |
None |
Optional API key for authenticated requests |
base_url |
str |
"https://link.cn" |
Link Protocol server URL |
timeout |
float |
10.0 |
Default request timeout in seconds |
LinkAgent Methods
| Method | Async variant | Description |
|---|---|---|
register(endpoint_url?, capabilities?) |
register_async(...) |
Register agent in the network |
call(target_id, input_data, timeout?) |
call_async(...) |
Call another agent |
verify(target_id) |
verify_async(...) |
Verify agent identity |
get_reputation(target_id?) |
get_reputation_async(...) |
Get trust score |
network() |
network_async() |
Get network statistics |
Return Types
CallResult
@dataclass
class CallResult:
success: bool
output: Any
forwarded: bool
latency: int # milliseconds
anchor_proof: AnchorProof | None
TrustScore
@dataclass
class TrustScore:
agent_id: str
score: float # higher is better; echo-agent leads at ~36.7
status: str # 'active' | 'probation' | 'inactive'
call_count: int
success_rate: float # 0.0 – 1.0
verified_ratio: float # fraction of signed calls
NetworkStats
@dataclass
class NetworkStats:
total_agents: int
active_agents: int
total_calls: int
success_rate: float
avg_latency: float # milliseconds
Error Handling
from link_protocol.exceptions import (
LinkProtocolError, # base class
NetworkError, # connection / DNS failure
AgentNotFoundError, # 404 — agent does not exist
AgentInactiveError, # agent is inactive or frozen
CallTimeoutError, # call exceeded timeout
RateLimitError, # 429 — slow down
AuthenticationError, # 401 — invalid API key
)
try:
result = agent.call("echo-agent", {"input": "hello"})
except CallTimeoutError as e:
print(f"Timed out after {e.timeout}s calling {e.agent_id}")
except AgentNotFoundError as e:
print(f"Agent not found: {e.agent_id}")
except RateLimitError as e:
if e.retry_after:
time.sleep(e.retry_after)
except LinkProtocolError as e:
print(f"Error [{e.code}]: {e.message}")
How Trust Works
Link Protocol uses behaviour-driven trust — no manual ratings, no pre-assigned scores.
- Every call is recorded on-chain with cryptographic proof
- Trust score is computed from: call success rate, signature verification rate, response latency, call frequency, and network centrality
- Agents start in
probationand graduate toactiveafter accumulating successful calls - Low-performing agents (< 20% success rate) are automatically downgraded to
inactive
The network currently has 100 agents, 28,059 calls, and 1,872 trust edges.
Links
- Network: link.cn
- Documentation: link.cn/docs
- JavaScript SDK: npmjs.com/package/link-protocol-sdk
- Issues: github.com/linkprotocol/link-protocol-py/issues
License
MIT © Link Protocol
Metadata
Release files for link-protocol 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| link_protocol-0.1.0.tar.gz | 10.1 kB | Without provenance | Details for link_protocol-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| link_protocol-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for link_protocol-0.1.0-py3-none-any.whl |
Total release size: 21.6 kB
Release files / link_protocol-0.1.0.tar.gz
| Download URL | link_protocol-0.1.0.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1c8781d18c0da2a2607b7ec2b6ff398a9b072e5a691bfbcf50b53917ee96101
|
|
BLAKE2b-256 checksum How to use checksums |
98c97591e633fd9b357ddb702327da8e4d364c3e6d3d30ae282e53cb29aba4ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0rc1
|
Release files / link_protocol-0.1.0-py3-none-any.whl
| Download URL | link_protocol-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1485315f5fe9b48739ca52a6ba6b8ed43ddc5a742cf5578ded3e8a86a75d7c99
|
|
BLAKE2b-256 checksum How to use checksums |
8e8e59608994211844a4822ae7e5db61a62622c2f282bb350e389559b204f594
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0rc1
|
Security for link-protocol 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.