Python client for the AgentScore APIs
Project description
agentscore-py
Python client for the AgentScore APIs.
Install
pip install agentscore-py
Quick Start
from agentscore import AgentScore
client = AgentScore(api_key="as_live_...")
# Look up cached reputation (free)
rep = client.get_reputation("0x1234...")
print(rep["score"]["value"], rep["score"]["grade"])
# Filter to a specific chain
base_rep = client.get_reputation("0x1234...", chain="base")
# Identity gate with policy (paid)
gated = client.assess("0x1234...", policy={
"require_kyc": True,
"require_sanctions_clear": True,
"min_age": 21,
})
if gated["decision"] == "deny":
print(gated["decision_reasons"]) # ["kyc_required"]
print(gated.get("verify_url")) # URL for operator verification
# Check verification level
rep = client.get_reputation("0x1234...")
print(rep.get("verification_level")) # "none" | "wallet_claimed" | "kyc_verified"
Credential-Based Identity
Agents without wallets can use operator credentials for identity:
result = client.assess(operator_token="opc_...")
print(result["decision"]) # "allow" | "deny"
Verification Sessions
Bootstrap identity for first-time agents. The success body carries structured next_steps (with action: "deliver_verify_url_and_poll") and a cross-merchant agent_memory hint. Poll responses carry next_steps.action from the typed NextStepsAction Literal (continue_polling, retry_merchant_request_with_operator_token, use_stored_operator_token, create_new_session, verification_failed, contact_support).
session = client.create_session()
print(session["verify_url"], session["poll_url"], session["poll_secret"])
print(session["next_steps"]["action"]) # "deliver_verify_url_and_poll"
status = client.poll_session(session["session_id"], session["poll_secret"])
if status["status"] == "verified":
print(status["operator_token"]) # "opc_..." — use for future requests
# Optional pre-association: attach the session to a known wallet or refresh KYC
# for an existing operator credential.
client.create_session(address="0x...")
client.create_session(operator_token="opc_...") # KYC refresh
Wallet resolution
assess() responses include resolved_operator and linked_wallets — all same-operator sibling wallets (claimed via SIWE or captured via prior associate_wallet). The list may mix EVM addresses (0x... lowercased) and Solana addresses (base58, case-preserved) for cross-chain operators; merchants doing wallet-signer-match checks should accept a payment signed by any address in the list, regardless of chain. The address parameter on assess() and get_reputation() accepts either format — network is auto-detected from the address shape.
Credential Management
cred = client.create_credential(label="my-agent", ttl_days=7)
print(cred["credential"]) # shown once
credentials = client.list_credentials()
client.revoke_credential(cred["id"])
Report an Agent's Wallet (Cross-Merchant Attribution)
After an agent authenticated via operator_token completes a payment, report the signer wallet so AgentScore can build a cross-merchant credential↔wallet profile. Fire-and-forget — first_seen is informational only. network is the key-derivation family: "evm" for any EVM chain (Base, Tempo, Ethereum, …) or "solana" for Solana.
client.associate_wallet(
operator_token="opc_...",
wallet_address=signer_from_payment, # e.g. EIP-3009 `from` or Tempo MPP DID address
network="evm",
idempotency_key=payment_intent_id, # optional — agent retries of the same payment no-op
)
Async
All methods have async variants prefixed with a:
async with AgentScore(api_key="as_live_...") as client:
rep = await client.aget_reputation("0x1234...")
result = await client.aassess("0x1234...", policy={"require_kyc": True})
# Identity model methods
session = await client.acreate_session()
status = await client.apoll_session(session["session_id"], session["poll_secret"])
cred = await client.acreate_credential(label="my-agent")
await client.alist_credentials()
await client.arevoke_credential(cred["id"])
await client.aassociate_wallet(
operator_token="opc_...",
wallet_address="0x...",
network="evm",
)
Context Manager
with AgentScore(api_key="as_live_...") as client:
rep = client.get_reputation("0x1234...")
Configuration
| Parameter | Default | Description |
|---|---|---|
api_key |
None |
API key from agentscore.sh |
base_url |
https://api.agentscore.sh |
API base URL |
timeout |
10.0 |
Request timeout (seconds) |
user_agent |
None |
Prepended to the default User-Agent as "{user_agent} (agentscore-py/{version})". Use to attribute API calls to your app. |
AgentScoreError.status is a property aliasing .status_code so polyglot codebases can use the same attribute name regardless of which SDK raised the error.
Error Handling
from agentscore import AgentScore, AgentScoreError
try:
rep = client.get_reputation("0xinvalid")
except AgentScoreError as e:
print(e.code, e.status_code, str(e))
AgentScoreError.details carries the rest of the response body — verify_url, linked_wallets, claimed_operator, actual_signer, expected_signer, reasons, agent_memory — so callers can branch on granular denial codes without re-parsing:
try:
client.assess("0xabc...", policy={"require_kyc": True})
except AgentScoreError as e:
if e.code == "wallet_signer_mismatch":
print("Re-sign from one of:", e.details.get("linked_wallets"))
elif e.code == "token_expired":
print("Verify at:", e.details.get("verify_url"))
Documentation
License
Project details
Release history Release notifications | RSS feed
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 agentscore_py-2.0.1.tar.gz.
File metadata
- Download URL: agentscore_py-2.0.1.tar.gz
- Upload date:
- Size: 50.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
518fac4749aeaaca3a895087d2cb3f6d4e264db15fb194c2a59d4a35bb986a45
|
|
| MD5 |
76e66e6098bc64c26a7bbaf5f672ca36
|
|
| BLAKE2b-256 |
7232861a7b4d19f677f103ac2b54462e121f76906dbc5ef0119d283ae9276af1
|
Provenance
The following attestation bundles were made for agentscore_py-2.0.1.tar.gz:
Publisher:
publish.yml on agentscore/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentscore_py-2.0.1.tar.gz -
Subject digest:
518fac4749aeaaca3a895087d2cb3f6d4e264db15fb194c2a59d4a35bb986a45 - Sigstore transparency entry: 1408061997
- Sigstore integration time:
-
Permalink:
agentscore/python-sdk@8ca4a15652d21f3b7cca5059cdea1be9cfe3d9fb -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/agentscore
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ca4a15652d21f3b7cca5059cdea1be9cfe3d9fb -
Trigger Event:
push
-
Statement type:
File details
Details for the file agentscore_py-2.0.1-py3-none-any.whl.
File metadata
- Download URL: agentscore_py-2.0.1-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
141eee41337e2156b9324527981f64a6edbdc375c4c218dd8c8d17cb287e1281
|
|
| MD5 |
bbf5dc8e55661f39c08481a17d6fa6e7
|
|
| BLAKE2b-256 |
324bbb898c79e62e4b4c4d9e8b4f621192ceeecdcd03fff2d12a50f00e74a800
|
Provenance
The following attestation bundles were made for agentscore_py-2.0.1-py3-none-any.whl:
Publisher:
publish.yml on agentscore/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentscore_py-2.0.1-py3-none-any.whl -
Subject digest:
141eee41337e2156b9324527981f64a6edbdc375c4c218dd8c8d17cb287e1281 - Sigstore transparency entry: 1408062117
- Sigstore integration time:
-
Permalink:
agentscore/python-sdk@8ca4a15652d21f3b7cca5059cdea1be9cfe3d9fb -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/agentscore
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ca4a15652d21f3b7cca5059cdea1be9cfe3d9fb -
Trigger Event:
push
-
Statement type: