Rest – How to acquire data and render page in context of REST/API application

apiapplication-designrest

In typical REST/API application, build on MVC architectural pattern, what is the best available technique for acquiring data for rendering views?

Should it be:

  • as in any non-API application: data is acquired directly from DB (through models), as in classical MVC, and controllers are rendering views basing on standard model data, and forms sends data through typical POST,

  • since this is an API application, even its very own website should be a client, that acquires data through API requests only and controllers are rendering views basing on JSON-like data, and forms must encode data to a typical JSON and push it API-way, just like an average JSON PUT request,

  • something else.

This question may sound silly or even naive. Unfortunately, I'm a very beginner to API/REST topic. Sorry.

Best Answer

If the data will be consumed by something else, either a frontend UI or another application somewhere else on the Internet, then you need a REST API.

Otherwise, you don't.

Related Topic