botvisibility 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ """BotVisibility — Python SDK.
2
+
3
+ Lighthouse for AI agents. Scan any URL across 58 checks and 5 levels
4
+ (Discoverable, Usable, Optimized, Indexable, Agent-Native) for AI-agent
5
+ readiness. See https://botvisibility.com/docs
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from .client import DEFAULT_BASE_URL, Client, __version__
10
+ from .errors import (
11
+ APIError,
12
+ BotVisibilityError,
13
+ InvalidURLError,
14
+ PaymentRequiredError,
15
+ )
16
+ from .models import Check, ScanResult, Score
17
+
18
+ __all__ = [
19
+ "Client",
20
+ "ScanResult",
21
+ "Score",
22
+ "Check",
23
+ "BotVisibilityError",
24
+ "APIError",
25
+ "InvalidURLError",
26
+ "PaymentRequiredError",
27
+ "DEFAULT_BASE_URL",
28
+ "__version__",
29
+ ]
botvisibility/cli.py ADDED
@@ -0,0 +1,64 @@
1
+ """Command-line interface: ``botvisibility <url>``."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import json
6
+ import sys
7
+ from typing import List, Optional
8
+
9
+ from .client import Client
10
+ from .errors import BotVisibilityError, PaymentRequiredError
11
+
12
+
13
+ def main(argv: Optional[List[str]] = None) -> int:
14
+ parser = argparse.ArgumentParser(
15
+ prog="botvisibility",
16
+ description="Scan a URL for AI agent readiness (BotVisibility).",
17
+ )
18
+ parser.add_argument("url", help="URL to scan, e.g. stripe.com")
19
+ parser.add_argument("--json", action="store_true", help="Print the raw JSON report")
20
+ parser.add_argument("--base-url", default=None, help="Override the API base URL")
21
+ parser.add_argument("--api-key", default=None, help="X-API-Key for a higher rate limit")
22
+ args = parser.parse_args(argv)
23
+
24
+ kwargs = {}
25
+ if args.base_url:
26
+ kwargs["base_url"] = args.base_url
27
+ if args.api_key:
28
+ kwargs["api_key"] = args.api_key
29
+
30
+ try:
31
+ with Client(**kwargs) as client:
32
+ result = client.scan(args.url)
33
+ except PaymentRequiredError as e:
34
+ print("Payment required: {0} (pay at {1})".format(e, e.paid_endpoint), file=sys.stderr)
35
+ return 2
36
+ except BotVisibilityError as e:
37
+ print("Error: {0}".format(e), file=sys.stderr)
38
+ return 1
39
+
40
+ if args.json:
41
+ print(json.dumps(result.raw, indent=2))
42
+ return 0
43
+
44
+ s = result.score
45
+ print("BotVisibility — {0}".format(result.url))
46
+ print(" Level {0}: {1} ({2})".format(s.level, s.level_name, s.grade))
47
+ print(
48
+ " {0} passed / {1} failed / {2} partial / {3} n/a (of {4})".format(
49
+ s.passed, s.failed, s.partial, s.na, s.total
50
+ )
51
+ )
52
+ fails = result.failing()
53
+ if fails:
54
+ print(" Top failures:")
55
+ for c in fails[:5]:
56
+ line = " - [{0}] {1}".format(c.id, c.name)
57
+ if c.recommendation:
58
+ line += " → " + c.recommendation
59
+ print(line)
60
+ return 0
61
+
62
+
63
+ if __name__ == "__main__":
64
+ raise SystemExit(main())
@@ -0,0 +1,120 @@
1
+ """Synchronous BotVisibility API client."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Any, Dict, Iterable, List, Optional
5
+ from urllib.parse import quote
6
+
7
+ import httpx
8
+
9
+ from .errors import APIError, InvalidURLError, PaymentRequiredError
10
+ from .models import ScanResult
11
+
12
+ DEFAULT_BASE_URL = "https://botvisibility.com"
13
+ __version__ = "0.1.0"
14
+
15
+
16
+ class Client:
17
+ """A thin, typed client over the BotVisibility REST API.
18
+
19
+ Example::
20
+
21
+ from botvisibility import Client
22
+
23
+ with Client() as bv:
24
+ result = bv.scan("stripe.com")
25
+ print(result.level_name, result.grade)
26
+ for c in result.failing():
27
+ print(c.id, c.name, "->", c.recommendation)
28
+
29
+ Args:
30
+ base_url: API origin. Defaults to https://botvisibility.com.
31
+ api_key: Optional ``X-API-Key`` for a higher rate limit.
32
+ token: Optional OAuth 2.0 bearer token (``scan:read`` scope).
33
+ timeout: Per-request timeout in seconds. Scans can take a while.
34
+ transport: Optional httpx transport (used for testing).
35
+ """
36
+
37
+ def __init__(
38
+ self,
39
+ base_url: str = DEFAULT_BASE_URL,
40
+ api_key: Optional[str] = None,
41
+ token: Optional[str] = None,
42
+ timeout: float = 60.0,
43
+ transport: Optional[httpx.BaseTransport] = None,
44
+ ):
45
+ self.base_url = base_url.rstrip("/")
46
+ headers = {
47
+ "Accept": "application/json",
48
+ "User-Agent": "botvisibility-python/" + __version__,
49
+ }
50
+ if api_key:
51
+ headers["X-API-Key"] = api_key
52
+ if token:
53
+ headers["Authorization"] = "Bearer " + token
54
+ self._client = httpx.Client(
55
+ base_url=self.base_url,
56
+ headers=headers,
57
+ timeout=timeout,
58
+ transport=transport,
59
+ )
60
+
61
+ # --- lifecycle ---
62
+ def __enter__(self) -> "Client":
63
+ return self
64
+
65
+ def __exit__(self, *exc: Any) -> None:
66
+ self.close()
67
+
68
+ def close(self) -> None:
69
+ self._client.close()
70
+
71
+ # --- API ---
72
+ def scan(self, url: str) -> ScanResult:
73
+ """Scan a single URL and return the full report.
74
+
75
+ Raises:
76
+ InvalidURLError: the URL was rejected (HTTP 400).
77
+ PaymentRequiredError: daily free allowance exceeded (HTTP 402).
78
+ APIError: any other non-2xx response.
79
+ """
80
+ resp = self._client.get("/api/scan", params={"url": url, "format": "json"})
81
+ return self._handle_scan(resp)
82
+
83
+ def compare(self, urls: Iterable[str]) -> List[ScanResult]:
84
+ """Scan several URLs and return their results in order."""
85
+ return [self.scan(u) for u in urls]
86
+
87
+ def badge_url(self, url: str) -> str:
88
+ """Return the SVG badge URL for a site (no request is made)."""
89
+ return self.base_url + "/api/badge?url=" + quote(url, safe="")
90
+
91
+ # --- internals ---
92
+ def _handle_scan(self, resp: httpx.Response) -> ScanResult:
93
+ if resp.status_code == 200:
94
+ return ScanResult.from_dict(resp.json())
95
+
96
+ body = self._safe_json(resp)
97
+ detail = (body or {}) if isinstance(body, dict) else {}
98
+
99
+ if resp.status_code == 400:
100
+ raise InvalidURLError(detail.get("message") or detail.get("error") or "Invalid URL")
101
+ if resp.status_code == 402:
102
+ raise PaymentRequiredError(
103
+ detail.get("message") or "Daily free allowance exceeded",
104
+ paid_endpoint=detail.get("paid_endpoint"),
105
+ limit=detail.get("limit"),
106
+ protocol=detail.get("protocol"),
107
+ body=body,
108
+ )
109
+ raise APIError(
110
+ "BotVisibility API error " + str(resp.status_code),
111
+ status=resp.status_code,
112
+ body=body,
113
+ )
114
+
115
+ @staticmethod
116
+ def _safe_json(resp: httpx.Response) -> Optional[Dict[str, Any]]:
117
+ try:
118
+ return resp.json()
119
+ except Exception:
120
+ return None
@@ -0,0 +1,42 @@
1
+ """Typed exceptions raised by the BotVisibility client."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Any, Optional
5
+
6
+
7
+ class BotVisibilityError(Exception):
8
+ """Base class for all SDK errors."""
9
+
10
+
11
+ class APIError(BotVisibilityError):
12
+ """The API returned an unexpected (non-2xx, non-handled) status."""
13
+
14
+ def __init__(self, message: str, status: Optional[int] = None, body: Any = None):
15
+ super().__init__(message)
16
+ self.status = status
17
+ self.body = body
18
+
19
+
20
+ class InvalidURLError(BotVisibilityError):
21
+ """The URL passed to scan() was rejected (HTTP 400)."""
22
+
23
+
24
+ class PaymentRequiredError(BotVisibilityError):
25
+ """The daily free allowance was exceeded (HTTP 402).
26
+
27
+ Carries the x402 payment pointer so callers can settle and retry.
28
+ """
29
+
30
+ def __init__(
31
+ self,
32
+ message: str,
33
+ paid_endpoint: Optional[str] = None,
34
+ limit: Optional[int] = None,
35
+ protocol: Optional[str] = None,
36
+ body: Any = None,
37
+ ):
38
+ super().__init__(message)
39
+ self.paid_endpoint = paid_endpoint
40
+ self.limit = limit
41
+ self.protocol = protocol
42
+ self.body = body
@@ -0,0 +1,110 @@
1
+ """Typed models for BotVisibility scan results.
2
+
3
+ Mirrors the JSON returned by GET /api/scan?format=json. Every model keeps the
4
+ original ``raw`` dict so callers can reach fields the SDK doesn't surface yet.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ from dataclasses import dataclass, field
9
+ from typing import Any, Dict, List, Optional
10
+
11
+
12
+ @dataclass
13
+ class Check:
14
+ """A single agent-readiness check result."""
15
+
16
+ id: str
17
+ name: str
18
+ status: str # "pass" | "fail" | "partial" | "na"
19
+ passed: bool
20
+ level: int
21
+ category: Optional[str] = None
22
+ message: Optional[str] = None
23
+ recommendation: Optional[str] = None
24
+ details: Optional[str] = None
25
+ found_at: Optional[str] = None
26
+ raw: Dict[str, Any] = field(default_factory=dict, repr=False)
27
+
28
+ @classmethod
29
+ def from_dict(cls, d: Dict[str, Any]) -> "Check":
30
+ return cls(
31
+ id=str(d.get("id", "")),
32
+ name=d.get("name", ""),
33
+ status=d.get("status", ""),
34
+ passed=bool(d.get("passed", False)),
35
+ level=int(d.get("level", 0) or 0),
36
+ category=d.get("category"),
37
+ message=d.get("message"),
38
+ recommendation=d.get("recommendation"),
39
+ details=d.get("details"),
40
+ found_at=d.get("foundAt"),
41
+ raw=d,
42
+ )
43
+
44
+
45
+ @dataclass
46
+ class Score:
47
+ """Top-level summary optimized for agents."""
48
+
49
+ passed: int
50
+ failed: int
51
+ partial: int
52
+ na: int
53
+ total: int
54
+ level: int
55
+ level_name: str
56
+ grade: str # "perfect" | "good" | "fair" | "needs-work"
57
+ raw: Dict[str, Any] = field(default_factory=dict, repr=False)
58
+
59
+ @classmethod
60
+ def from_dict(cls, d: Dict[str, Any]) -> "Score":
61
+ return cls(
62
+ passed=int(d.get("passed", 0) or 0),
63
+ failed=int(d.get("failed", 0) or 0),
64
+ partial=int(d.get("partial", 0) or 0),
65
+ na=int(d.get("na", 0) or 0),
66
+ total=int(d.get("total", 0) or 0),
67
+ level=int(d.get("level", 0) or 0),
68
+ level_name=d.get("levelName", ""),
69
+ grade=d.get("grade", ""),
70
+ raw=d,
71
+ )
72
+
73
+
74
+ @dataclass
75
+ class ScanResult:
76
+ """A full BotVisibility scan of a single URL."""
77
+
78
+ url: str
79
+ score: Score
80
+ current_level: int
81
+ checks: List[Check]
82
+ timestamp: Optional[str] = None
83
+ raw: Dict[str, Any] = field(default_factory=dict, repr=False)
84
+
85
+ @classmethod
86
+ def from_dict(cls, d: Dict[str, Any]) -> "ScanResult":
87
+ return cls(
88
+ url=d.get("url", ""),
89
+ score=Score.from_dict(d.get("score", {}) or {}),
90
+ current_level=int(d.get("currentLevel", 0) or 0),
91
+ checks=[Check.from_dict(c) for c in d.get("checks", []) or []],
92
+ timestamp=d.get("timestamp"),
93
+ raw=d,
94
+ )
95
+
96
+ # --- convenience accessors ---
97
+ @property
98
+ def grade(self) -> str:
99
+ return self.score.grade
100
+
101
+ @property
102
+ def level_name(self) -> str:
103
+ return self.score.level_name
104
+
105
+ def failing(self) -> List[Check]:
106
+ """Checks that failed outright (status == 'fail')."""
107
+ return [c for c in self.checks if c.status == "fail"]
108
+
109
+ def passing(self) -> List[Check]:
110
+ return [c for c in self.checks if c.status == "pass"]
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.4
2
+ Name: botvisibility
3
+ Version: 0.1.0
4
+ Summary: Python SDK for BotVisibility — Lighthouse for AI agents. Scan any URL across 58 checks and 5 levels for AI-agent readiness.
5
+ Project-URL: Homepage, https://botvisibility.com
6
+ Project-URL: Documentation, https://botvisibility.com/docs
7
+ Project-URL: Source, https://github.com/jjanisheck/botvisibility
8
+ Author: Joey Janisheck
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: aeo,agent-readiness,agents,ai,botvisibility,geo,llms.txt,mcp,openapi
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Internet :: WWW/HTTP
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.9
24
+ Requires-Dist: httpx>=0.24
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # botvisibility (Python SDK)
30
+
31
+ Python client for [**BotVisibility**](https://botvisibility.com) — Lighthouse
32
+ for AI agents. Scan any URL across 58 checks and 5 levels (Discoverable, Usable,
33
+ Optimized, Indexable, Agent-Native) to see how ready it is for AI agents like
34
+ Claude and GPT.
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ pip install botvisibility
40
+ ```
41
+
42
+ ## Quick start
43
+
44
+ ```python
45
+ from botvisibility import Client
46
+
47
+ with Client() as bv:
48
+ result = bv.scan("stripe.com")
49
+
50
+ print(result.url, "->", f"Level {result.score.level}: {result.level_name} ({result.grade})")
51
+ print(f"{result.score.passed} passed / {result.score.failed} failed")
52
+
53
+ for check in result.failing():
54
+ print(f" [{check.id}] {check.name} → {check.recommendation}")
55
+ ```
56
+
57
+ ### Compare sites
58
+
59
+ ```python
60
+ with Client() as bv:
61
+ for r in bv.compare(["stripe.com", "twilio.com"]):
62
+ print(r.url, r.level_name, r.grade)
63
+ ```
64
+
65
+ ### Badge URL
66
+
67
+ ```python
68
+ Client().badge_url("stripe.com")
69
+ # -> "https://botvisibility.com/api/badge?url=stripe.com"
70
+ ```
71
+
72
+ ## Authentication
73
+
74
+ Public access needs no credentials. To raise your daily allowance, pass an
75
+ OAuth 2.0 `scan:read` bearer token or an API key:
76
+
77
+ ```python
78
+ Client(token="…") # Authorization: Bearer …
79
+ Client(api_key="…") # X-API-Key: …
80
+ ```
81
+
82
+ See <https://botvisibility.com/auth.md>.
83
+
84
+ ## Errors
85
+
86
+ ```python
87
+ from botvisibility import Client, PaymentRequiredError, InvalidURLError, APIError
88
+
89
+ try:
90
+ Client().scan("example.com")
91
+ except PaymentRequiredError as e:
92
+ # Over the free allowance — settle via x402 and retry.
93
+ print("Pay at", e.paid_endpoint)
94
+ except InvalidURLError:
95
+ ...
96
+ except APIError as e:
97
+ print(e.status, e.body)
98
+ ```
99
+
100
+ ## CLI
101
+
102
+ ```bash
103
+ botvisibility stripe.com # human-readable summary
104
+ botvisibility stripe.com --json # raw JSON report
105
+ ```
106
+
107
+ ## Development
108
+
109
+ ```bash
110
+ pip install -e ".[dev]"
111
+ pytest
112
+ ```
113
+
114
+ ## License
115
+
116
+ MIT © Joey Janisheck. Not affiliated with any third party; see
117
+ <https://botvisibility.com>.
@@ -0,0 +1,10 @@
1
+ botvisibility/__init__.py,sha256=ojvuXlYAZwey2CbB1EUBWRVe1tLqJFI_sict1hecEUg,682
2
+ botvisibility/cli.py,sha256=ODh8TzNg_7ZFZYW6NQdja7x66eUXW0LKAhzeUcYWz7g,2061
3
+ botvisibility/client.py,sha256=---Df_RgJ_Ex4saocRj8x64Pd3YnaZGhlCx6Q5CqcVE,3932
4
+ botvisibility/errors.py,sha256=_j2s15Ix7fhTLcDV7zFuAkcijs67e1FXEYu8WT6W8DA,1156
5
+ botvisibility/models.py,sha256=lttLJZMSF1kiLvesPg7GZEd1MkVPYPhSacDiRcupcEU,3232
6
+ botvisibility-0.1.0.dist-info/METADATA,sha256=SD9tPN-Scow5i3jIUqwJHnVz8ONf2iWb9slBjhUpwnI,3176
7
+ botvisibility-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ botvisibility-0.1.0.dist-info/entry_points.txt,sha256=Qn6bG-bVw12FhxBAslb4aMLrWtyHaprucZnabkczp7A,57
9
+ botvisibility-0.1.0.dist-info/licenses/LICENSE,sha256=zCf50UN-W74S2is6L6qaRW41XUzgcXspoMOTf4Q7rI4,1071
10
+ botvisibility-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ botvisibility = botvisibility.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joey Janisheck
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.