CMake file-api is the canonical way to programmatically interact with CMake from external build systems and tools. CMake file-api uses JSON files to communicate CMake state and target graph to external tools. CMake file-api replaces the removed cmake-server API. CTest can output JSON describing the test graph, especially useful to understand complex test dependencies including test fixtures.
A complete standalone example of using CMake file-api from Python helps illustrate these ideas.