In reply to mark k..

@mark k.

OriginalEXE didn't go into details, but just to put things into perspective, our Node.js code tiny, a couple hundred lines altogether (probably smaller than most WP plugins) and all it does is to prerender content for the various URL routes. It doesn't even know about the WP API or templates as that's actually already React code. So it's really just an extension of the browser side code, which it can run as both are JS runtimes.

Whereas if you were to go directly to the database you'd need to understand the structure of WP and also as far as I know any plugin can alter the database, so deal with unknown and practically infinite variations if some content is extended by and created with a plugin. And it will be guaranteed to break as soon as the database structure is changed. The point of having an API is that it's an interface which is agreed on, won't change without a notice and is optimised to efficiently retrieve the data, coded by people who intimately know WP.

So yes, while theoretically you could save some resources with Node.js directly going to the database and using optimised queries, actually doing it unpractical to the point that it's almost impossible. But don't forget that any non-trivial WP installation will have some cache, ours for example stores API responses in Memcached which is orders of magnitude faster than anything trying to read the database.