I have an endpoint for a REST API that checks for the existence of a (or a list of) requests.
It can return 200 OK if there is an order in progress
or 404 NOT FOUND if there are no current orders
Creating an availability SLO for this API, I noticed that a high percentage of requests made to this route results in a 404 status code, decreasing the availability percentage.
Is it correct to think that if no request was found, it doesn't mean that resource was not found?
Because it was possible to work on the resource, and what it found was an empty list, in which case the correct return would be 200OK
Both
200 OKand404 NOT FOUNDfulfills the HTTP standard. For non existing item resources e.g./items/1I would go with404for empty collection resources/items/?q=blahI would go with200and an empty JSON array,[]. In that context I think404means that there is no route matching the URI.As of mixing item resources and collection resources, I think it is a very bad idea. You need to add an if-else to the client and check if the response contains an object or an array. I would rather go with two different URI templates, one for the item and one for the collection.