Python API Reference
The ranex package exposes a small Python API that wraps a native extension.
Import:
from ranex import Atlas, Firewall, ArtifactKind, init_logging, versionAtlas
Create an instance:
Atlas(project_root)Key methods:
Indexing
scan()
Search
search(query, limit=...)search_by_feature(feature)
Health
count()health()
Dependency and impact
get_dependencies(file_path)get_dependents(file_path)analyze_file_impact(file_path)analyze_function_impact(qualified_name)
Quality and structure
detect_patterns()get_patterns()find_duplicates()detect_cycles()
Span utilities
glob_python_files(pattern, limit=...)grep_spans(query, limit=..., path_glob=...)search_spans(query, limit=...)read_span(file_path, line_start, line_end, max_bytes=...)
FastAPI analysis
fastapi_scaling_policy()analyze_fastapi_scaling()analyze_fastapi_router_topology()fastapi_truth_capsule(...)
Firewall
Create an instance:
Firewall(project_root)Key methods:
check_import(import_path)check_imports([import_path, ...])analyze_file(file_path)check_typosquat(package_name)
Policy inspection:
policy_mode(property)get_policy_info()list_rules()get_allowed_packages()get_blocked_patterns()
ArtifactKind
ArtifactKind provides string constants used in Atlas results:
ArtifactKind.FUNCTIONArtifactKind.ASYNC_FUNCTIONArtifactKind.CLASSArtifactKind.METHODArtifactKind.ENDPOINTArtifactKind.CONTRACTArtifactKind.MODELArtifactKind.CONSTANT
Logging
init_logging(level=...)Levels: trace, debug, info, warn, error
Version
version()returns the installed Ranex version.ranex.__version__is also available.