Wordpress创建自定义休息服务

I'm developing a wordpress plugin and I would like to create a page with JSON output with some custom db queries that I will use from javascript.

What are best practices?

I tried to use wp-api with a custom controller, but I don't need that plugin..

Maybe is better to create a custom .php file that will use wordpress objects for querying database with json output?

Thanks

I chose to create a custom .php file, I don't know if it's the better choice, but it works :)

<?php
header('Content-Type: application/json');
if ($_SERVER['REQUEST_METHOD'] = 'GET') {
    require_once '../../../../wp-blog-header.php';
    require_once '../includes/engine.php';

    $engine = new Engine();
    echo json_encode($engine->Data());
}