Skip to main content

Python client for the Agent Disco API — grade any public URL for AI-agent discoverability.

Project description

agentdisco — Python client for Agent Disco

PyPI version Python versions MIT License CI

Grade any public URL for AI-agent discoverability. Thin Python wrapper over the REST API at https://agentdisco.io/api/v1.

Install

pip install agentdisco

Requires Python 3.9+.

Quick start

Submit a scan (anonymous, 10 scans/day/IP)

from agentdisco import AgentDisco

with AgentDisco() as client:
    scan = client.submit_scan("https://example.com")
    print(scan.id, scan.status)

Poll until complete

import time

with AgentDisco() as client:
    scan = client.submit_scan("https://example.com")
    while scan.status not in {"completed", "failed"}:
        time.sleep(5)
        scan = client.get_scan(scan.id)

    print(f"grade: {scan.grade} ({scan.score}/100)")

Mint a key (raises your quota to 100 scans/day)

from agentdisco import AgentDisco

# Unauthenticated mint — no prior token needed, rate-limited at
# 5 keys/hour/IP. Token is shown ONCE; store it.
key = AgentDisco().mint_key()
print(key.token)  # ak_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

authed = AgentDisco(token=key.token)
authed.submit_scan("https://your-site.example")

Get summary for a previously-scanned host

with AgentDisco() as client:
    site = client.get_website("example.com")
    print(site.latest_grade, site.latest_score, site.scan_count)

Sign in with the Colony (agents)

Autonomous agents on The Colony can authenticate without a browser. Exchange your Colony agent token for an authenticated-tier Agent Disco key — OAuth 2.0 Token Exchange (RFC 8693), no redirect:

from agentdisco import AgentDisco

# One-liner: exchange a Colony agent token and get an authed client.
client = AgentDisco.from_colony_token(my_colony_token)
client.submit_scan("https://your-site.example")     # authenticated tier (500/day)

# Or keep the minted key's plaintext to reuse across processes:
key = AgentDisco().exchange_colony_token(my_colony_token)
print(key.token, key.rate_limit_tier)                # ak_…  authenticated

Agent-only: a human Colony subject is rejected with UnauthorizedError.

Higher rate limits

Authenticated-tier keys (500 scans/day/key) need a signed-in account, or a Colony agent login (above). Sign up at https://agentdisco.io/register, then mint via the web form at https://agentdisco.io/developers.

Tier Rate limit How to get
Anonymous (no key) 10 scans / day / IP default
Anonymous key 100 scans / day / key mint_key() above
Authenticated key 500 scans / day / key sign in (/developers) or from_colony_token()

Error handling

from agentdisco import (
    AgentDisco,
    InvalidUrlError,
    NotFoundError,
    RateLimitedError,
)

try:
    scan = AgentDisco().submit_scan("https://example.com")
except InvalidUrlError as e:
    print(f"URL rejected: {e}")
except RateLimitedError as e:
    print(f"quota exceeded; retry in {e.retry_after_seconds}s")
except NotFoundError as e:
    print(f"not found: {e}")

All SDK-raised exceptions inherit from AgentDiscoError, so a single broad catch works too:

from agentdisco import AgentDiscoError
try:
    ...
except AgentDiscoError as e:
    log.warning("agentdisco failure: %s", e)

Network-layer failures (connection timeout, DNS) leak through as raw httpx.HTTPError — they're platform issues, not API errors.

Custom base URL

For self-hosted deployments or local testing:

AgentDisco(base_url="http://localhost:1977")

Links

Licence

MIT. See LICENSE. The scanner itself is operated by Starsol Ltd (England, company 06002018); only this client library is open-source. Issues + pull requests welcome.

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

agentdisco-0.2.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentdisco-0.2.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file agentdisco-0.2.0.tar.gz.

File metadata

  • Download URL: agentdisco-0.2.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for agentdisco-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b312fdad2f311c9c2804b1599978c554fcaac6c3edf0aa13a1b5392ed7d14515
MD5 9eae4b2b5e191ebfdf36fe79000e84de
BLAKE2b-256 54f1138b135168e2b5f9d14dd08fb4278d31e1cd706dbce8c5b5ed140199d654

See more details on using hashes here.

File details

Details for the file agentdisco-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: agentdisco-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for agentdisco-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 914dddb219dfe5c680f8f49d0b432e4a66b493cd7dcfff0f3287fba468381011
MD5 70dd90028ef6cc20d9e7e53ead4b638e
BLAKE2b-256 3ee89b00b8b35061ea473cc5880c0cf12ddc1b98af1a00d9a410d1d67d981739

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page