-1

I got a lot of questions today. I am trying to figure out this issue for almost a month .. Is the following code segment a rest API (it's in laravel)?

public function index() {
   $data = Data::get();
   return response()->json($data, 200); 
}

If yes, then why it is different from an API, if not then what will make it a rest api ? Someone told me it's nothing but a json response of data, Is that true ?

K.S. Azim
  • 89
  • 8
  • 1
    An REST API is a API, but an API is not necessarily a REST API. Did you read up on what a REST API exactly is? You can find this information online if you just look for it. – KIKO Software May 29 '22 at 21:42
  • 1
    The many great answers to [this question](https://stackoverflow.com/q/671118/1941241) might be of interest. – rickdenhaan May 29 '22 at 21:44
  • REST APIs meet well defined constraints. https://www.ics.uci.edu/~fielding/pubs/dissertation/fielding_dissertation.pdf Usually they respond with hypermedia instead of json, though most people don't understand this either. – inf3rno May 31 '22 at 16:10

0 Answers0