Should, for example, /books/:id return the Book with the given id and the various Authors? Or should it return the Book with the given id and the ids of the various Authors which can then be queried either via a bunch of queries to /authors/:id or /authors?ids=1,2,3, etc.?
Short story long. depends.
The representation of the resource identified by /books/x depends on how you want clients to consume, interact and discover the books and the related resources. Whether a Book should provide clients with authors`data or/and ids depends, mostly, on those things.
If you were developing a REST API for multiple clients, you would have to decide how you want them to consume your API and how many requests you want them to do for them to reach all the data. Among other things.
Would be different if the API would be only feeding a single client of your own. Let's say a mobile app or a web app. In these cases, these apps act like a lighthouse. Their needs use to dictate which representation suites better to their needs of UX, usability, efficiency, etc.
There could be other concerns to consider. As for example whether there's any security concern to take into account before clients go from books to authors. Do clients need special grants to fetch author's full detail? Or vice-versa, etc.
@VoinceOfUnreason already made a good point
Your REST API is an attempt to disguise your domain model as a web site. Let the web be your guide.
This is easier to conceptualize with HATEOAS
{
"title":"The Jungle Book",
"published":1894
"_link":{
"self":{ "href": "http://myserver/book/x"},
"authors":{ "href": "http://myserver/book/x/authors"}
},
"_embedded":{
"authors":[
{
"name": "Rudyard Kipling",
"_links:":{
"self":{ "href": "http://myserver/author/y"},
"books":{ "href": "http://myserver/author/y/books"}
}
}
}
}
The previous representation of /book/x would be the content of the page /book/x.page. Everything I deemed necessary for the clients to show the book as I want it to be is there. What's not, can be fetched following the _linksor the embedded resource links. In other words. In related pages/resources.
Of course, I could just have returned everything in a single request. However, I would had to weight first the consequences. For example, what happens when I have a collection of Books instead of a single one. How would the server behave with such need of load per book, page, etc. Under concurrency. And how would the database server behave under these conditions?
As you see, there's a lot of things that could influence the decision. That's why is hard for us to say what should you do. It's all up to your concrete needs and requirements. And also constraints.