Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST API to check if an object exists

Tags:

rest

I have currently a webservice that load an object which looks like /object/load?id=100, the problem is that my object is really huge and it takes a long time to get the full response of the webservice just to see if the object exists or not.

What is the best pratice here ?

  • Creating a new webservice /object/exists?id=100 thats only use HTTP status code (200 if object exists, 404 if not) ?

  • Add parameter to the /object/load webservice to return only simplified object ?

like image 388
robinvrd Avatar asked Sep 06 '25 03:09

robinvrd


1 Answers

If you are only interested in existence, or knowing in advance how the API will respond if you do a real GET request, HTTP actually has a built-in method for that: HEAD.

like image 146
Evert Avatar answered Sep 09 '25 17:09

Evert