How can I do this query with Cockpit? Need help

I found this and trying to replicate into Cockpit.

What I created: author with a single name, two categories and two books. How it’s possible to list on index site the same result as the response on stackoverflow?

I think when you are using the API you have to put the tables data together your self by getting data of both collection and then merging them manually. But I am not quite sure on this - I was never in need of joining data