ElementAPI endpoint routing syntax for multi-level structure
Quite a simple solution set the criteria to uri and you just pass the endpoint as is as a catch all.

$normal =  preg_replace('/.json/', '', craft()-&gt;request-&gt;path);
return [
        'endpoints' =&gt; [
            craft()-&gt;request-&gt;path =&gt; [
                'elementType' =&gt; 'Entry',
                'criteria' =&gt; ['uri' =&gt; $normal],
                'first' =&gt; true,
                'transformer' =&gt; new DetailTransformer(),
            ],
        ]
    ];