
apiverify
io.github.kumar-miskin/apiverify
Check if a Python API exists in an exact PyPI version, from source. verified/not_found/unknown.
Documentation
apiverify
Status: 0.1.7 is the latest release (adds source under
lib/, so PyYAML 6 now resolves; coverage only). 0.1.6 was the latest release (corrective fix for 0.1.5 and earlier). It builds on 0.1.2, which fixed the wrong answers that independent evaluations found in 0.1.0 and 0.1.1. An independent retest of 0.1.2's supported syntax boundary passed on 69 synthetic cases (42 decisive and correct, 27 abstained, 0 wrong); 0.1.3 was cleared on 86 synthetic probes (55 correct, 30 abstained, 1 unscored, 0 wrong). That is not proof of broad reliability: on real libraries it abstained on about 49% of probes, and one class-vs-instance attribute ambiguity remains. Not compared with other tools; no evidence yet that it helps agents. 0.1.0 could returnnot_foundfor names that exist at runtime (members inherited fromobject, members generated by class decorators, members attached after the class body, names made viaglobals()/exec) andverifiedfor conditional names (TYPE_CHECKING-only,del-ed, version-gated). 0.1.2 and later answercannot_verifyfor those, limits unpacking (only.py/.pyi, 100 MB total, 8 MB per file) and validates inputs. Expect manycannot_verifyanswers (the evaluation saw 46% abstention on lazily loaded or re-exporting libraries such as pydantic 2). Monkeypatching from a different module cannot be seen. Do not treat this as proven reliable.Known issue in 0.1.2 (fixed in 0.1.3): our own adversarial runtime check found wrong answers on a few constructs (names bound in loops,
with/match/:=, nested tuple unpacking,trybodies, star-import filtering, annotation-only names,globalin a class body). Use 0.1.3 or later; see CHANGELOG.md. The 0.1.3 fixes were checked by an independent evaluator on synthetic cases (0 wrong of 86 probes); that is not proof of reliability.Known issue in 0.1.3 (fixed in 0.1.4): when a package binds a name that is also one of its own submodules (found on pyparsing 3.1.2, where
from .common import pyparsing_common as commonhides thecommonsubmodule), 0.1.3 can answerverifiedfor names under it that do not exist at runtime (for examplepyparsing.common.Empty.try_parse). 0.1.4 answerscannot_verifythere, including when the package also hasfrom . import common. It over-abstains on real names under such aliases. One gray zone remains: an alias imported only underTYPE_CHECKINGcan still resolve through the submodule, although the attribute may be absent after a plainimport pkg. The fix was checked by an independent evaluator on synthetic packages and 41 pyparsing probes; library samples in our own runs (an even sample of public names per library, not exhaustive) showed 0 wrong. That is not proof of reliability.Known issue in 0.1.4 and earlier (fixed in 0.1.5): a module inside a package that runs
import pkg(orimport pkg.sub) on its own package binds the namepkgin that module, for examplepytz/tzinfo.pydoesimport pytz. For such a name, for examplepytz.tzinfo.pytz, 0.1.4 and earlier can answernot_foundalthough the attribute exists at runtime. 0.1.5 answerscannot_verifythere. Found in our own sampled runs on pytz; confirmed by an independent evaluator. Not proof of reliability. Remaining gaps: packages whose source sits underlib/in the sdist (for example PyYAML) gotcannot_verifyfor every name before 0.1.7. 0.1.7 resolves them, except where alib3/sits next tolib/(old PyYAML), which still abstains. In PyYAML 6.0.2 a nonexistent name returnscannot_verify, notnot_found, because of its conditional star imports.Known issue in 0.1.5 and earlier (fixed in 0.1.6, narrowly): a module that defines a name with
def/classand also binds it with an unconditional import (for exampledef pkgthenimport pkg) could report the wrong kind, orverifiedfor a name that does not exist at runtime. 0.1.6 answerscannot_verifythere, and also for the commontry: from x import N/except ImportError: def Nfallback (a coverage cost, for example requests.adapters.SOCKSProxyManager). Independently checked on 3,034 sampled real-library verdicts (0 wrong) and synthetic cases. Binding order is not resolved in general: external-import order, star imports and assignment rebinding can still give wrong kinds. Not proof of reliability.
Does this Python API exist in this exact package version? apiverify answers from the published source of that version, not from docs or model memory.
Three answers only:
verified: found in the source. Returns file, line, signature, and deprecation signals. Kindinstance attributemeans it is assigned onselfin a method, not necessarily on the class itself.not_found: every lookup path was followed and the name is absent from the release's source, within the supported syntax boundary below. This is a source-only result, not a runtime guarantee.cannot_verify: the answer depends on something static analysis cannot settle (module-level__getattr__, a base class or re-export from outside the package, a file that will not parse). The agent should not assume either way.
It downloads the release from PyPI, checks the sha256 PyPI lists for it, unpacks it
safely, and reads it with ast. It never imports or runs package code. No dependencies.
Use
python -m apiverify.cli requests.Session.get --version 2.31.0
python -m apiverify.cli requests.exceptions.JSONDecodeError -v 2.26.0 # not_found
python -m apiverify.cli requests.exceptions.JSONDecodeError -v 2.27.0 # verified
python -m apiverify.cli PIL.Image.open -v 10.0.0 --package pillow -k mode
Exit code: 0 verified, 1 not_found, 2 cannot_verify.
Install
pip install apiverify
uvx --from apiverify apiverify-mcp # run the MCP server without installing (note: the package is `apiverify`; there is no package named `apiverify-mcp`)
As an MCP server (stdio)
Tool: verify_python_api with symbol, version, optional package, kwargs.
Run command (any client): uvx --from apiverify apiverify-mcp. Pin a version with apiverify==0.1.7.
Needs uv installed. Config location and shape differ per client; checked against each client's docs on 2026-11-26:
- Claude Code:
claude mcp add apiverify -- uvx --from apiverify apiverify-mcp - Claude Desktop (
claude_desktop_config.json) and Cursor (mcp.json) both use a top-levelmcpServersobject:
{ "mcpServers": { "apiverify": { "command": "uvx", "args": ["--from", "apiverify", "apiverify-mcp"] } } }
- VS Code / Copilot: its config format is changing; use its guided "Add Server" flow, choose "Command (stdio)" and enter the run command above. Not tested by us.
- Other MCP clients: add a stdio server with that command. Not tested by us.
We have only smoke-tested the server over stdio (initialize + tools/list); we have not run it inside each client above.
(From a clone you can also use python -m apiverify.mcp_server.)
Suggested line for an agent's instructions file (AGENTS.md / CLAUDE.md): "Before calling a library API you are not certain exists in the project's pinned version, call verify_python_api. Treat cannot_verify as unknown, not as yes."
Tested scope (see eval/)
Unit tests: python -m unittest discover -s tests (offline fixtures, 14 tests).
Runtime comparison: python eval/run_eval.py installs exact versions of requests (4),
click (3) and flask (3), asks Python itself whether each candidate symbol exists, and
compares. This is the author's own run on the cases the tool was built against, so it does not
show reliability (see the warning above). Result in eval/last_run.txt: 2,411 correct, 0 false
positives, 0 false negatives, 442 abstentions (all flask, mostly names re-exported
from werkzeug/jinja2, which live outside the flask artifact), 2 instance attributes
not scored.
Supported syntax boundary (a static checker, not a Python interpreter)
verified / not_found are only returned for plain module-level code: def, class, simple assignments,
import / from ... import (including relative and star imports inside the same artifact), plain-name
base classes, Class.attr = value at module level, and literal __slots__. Anything else that could add,
remove or hide a name gives cannot_verify: conditional definitions (version/platform/feature checks, unless
both branches define it), TYPE_CHECKING-only names, del, class or alias rebinding, class decorators,
metaclasses, __getattr__, globals()/exec/eval/setattr, loops that assign attributes, and external
base classes or re-exports. It cannot see another module patching the class at import time.
Limits
- Python on PyPI only. No JavaScript, Rust or Go yet.
- Static analysis. Names created at runtime are reported as
cannot_verify, not guessed. - Not scored in the eval: keyword-argument checks, deprecation signals, and
instance attributeresults. - The eval's candidates mostly come from names that exist in some version, with only a few decoys per library, so it measures version differences well and hallucinated names weakly. It is three libraries, not a benchmark.
- It has not been compared against Context7 or any retrieval tool. That comparison needs an agent harness and model spend, and is not done.
- No evidence yet that developers would pay for it or that agents call it unprompted.
- Needs network access to pypi.org and files.pythonhosted.org. Artifacts are cached in
$APIVERIFY_CACHE.
Reaching agents
See DISTRIBUTION.md.
apiverifypip install apiverify