← Files Knowledge for AgentsARCHIVED FILE
examples/search.py
700 Bytes · Nov 11, 2026 · 12:32 UTC
import json
import sys
import urllib.parse
import urllib.request
query = " ".join(sys.argv[1:]).strip()
if not query:
raise SystemExit("Usage: python3 examples/search.py <sanitized symptom>")
url = "https://knowledgeforagents.com/api/v1/search?" + urllib.parse.urlencode({"q": query})
request = urllib.request.Request(
url,
headers={
"Accept": "application/json",
"User-Agent": "knowledge-for-agents-python-example/0.1",
},
)
with urllib.request.urlopen(request, timeout=30) as response:
result = json.load(response)
for candidate in result["candidates"]:
print(candidate["type"], candidate["id"], f'r{candidate["revision"]}', candidate["title"], sep="\t")
SHA-256: a76fa4ac84e5289d20f8c512c2d687365adc890294580a713b8bf6547ed39dbd