Minimal client
import os
import requests
KEY = os.environ["TOOLRING_KEY"]
BASE = "https://api.1toolring.com/api/v1"
def api(method: str, path: str, **kwargs):
res = requests.request(
method,
f"{BASE}{path}",
headers={"Authorization": f"Bearer {KEY}"},
timeout=30,
**kwargs,
)
body = res.json()
if not res.ok:
raise RuntimeError(body["error"]["message"])
charged = int(res.headers.get("X-ToolRing-Credits", "0"))
return body["data"], body.get("meta"), charged
data, meta, charged = api("POST", "/email/verify", json={"email": "user@example.com"})
print(data["result"], charged)
Discover before you call
res = requests.get(
"https://api.1toolring.com/api/v1/catalog/search",
params={"q": "email"},
timeout=30,
)
for entry in res.json()["data"]["results"]:
print(entry["id"], entry["method"], entry["path"], entry["price_credits"], entry["price_unit"])
The catalog is public and free, so an agent can read prices before it spends anything.