Code Tutorial
Create a Headless API for the TypeRocket Page Builder
Creating a headless API with TypeRocket Pro or TypeRocket Open can be done using routes and the ORM.
In your routes.php
file, create the following route.
tr_route()->get()->match('headless/page/([^/]+)', ['id'])->do(function($id) {
return (new \App\Models\Page)->where('ID', (int) $id)->with(['meta', 'author'])->first();
});
Now, when you access the URL /headless/page/2
the page with the ID of 2 will load as JSON with the meta fields and author fields. If you are using the page builder, it's components will get loaded into the meta.