Skip to content

REST Module

Exposes custom REST APIs using JAX-RS (Java API for RESTful Web Services).

  • Allow external systems to interact with Liferay (e.g., mobile apps).
  • Build headless applications.
Terminal window
blade create -t rest book-rest-api
book-rest-api/src/main/java/com/example/book/rest/BookResource.java
@Path("/books")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class BookResource {
@GET
public List<Book> getBooks() {
return BookService.getBooks(); // Your service logic
}
@POST
public Response addBook(Book book) {
BookService.addBook(book);
return Response.ok().build();
}
}
Terminal window
curl http://localhost:8080/o/book-rest-api/books
  • Mobile Apps: Fetch Liferay data via REST.
  • Third-Party Integrations: Sync data with CRM/ERP systems.