I am designing a REST API and throughout the API we have used HTTP Not found / 404 when an object/resource we are trying to access doesn't exist.
Ex: http://host/someobject/1
But the current one scenario is little different. I have the URI which searches the data with query parameters.
Ex: http://host/someObject/find?param1=param1value¶m2=param2value
The query parameters are optional but at least one criteria must be provided for successful request. I am currently returning empty list when search result is empty assuming the URI exists but data not present at the moment.
Can any one shed some light on this scenario ? Should I return empty array with Status code 200 or something else ?
TL;DR - return the same thing you would return with N results, using N = 0.
Keep in mind that, from the point of view of REST/HTTP, the URI above is not a query; it's an identifier for an information resource. The part of the identifier (which is named Query by the RFC-3986) is just "non-hierarchical data".
The fact that your implementation parses the URI, and uses the tokens it finds as inputs to a query is an implementation detail, and is deliberately hidden from the client by the uniform interface. (Consider, for instance, the case where the client GET request passes through a cache between the client and the server; the cache might use the URI as a lookup in a key value store, and -- finding a representation there -- will send the result back to the client without forwarding the request to the server).
Ideally, your resources and their representations will be stable, even when your implementation may not be.
Perfect.
Yes.
A quick overview
REST doesn't care what spelling you use for the resource identifier Neither does the web -- as far as the other parts of the web are concerned, your URIs are opaque. Client code is not supposed to be interpreting the identifiers, or relying on their interpretation in any way. The only thing that is supposed to care is the origin server (which needs to route the identifier to the appropriate implementation).
The "rule" you are quoting is analogous to a coding style guide recommending best practices for variable names. The motivation for the rule is based on REST and the web; not by specification, but by deeper ideas.... Fielding's definition of resources:
It follows that any resource that returns a representation must be a thing that has state. So naming guidelines encourage spellings that identify the resource as a noun, rather than a verb.
"Find me the objects that satisfy these constraints" is what your URI says, but that's not aligned with the concept of resources. The guidelines are encouraging you to instead think "Get me the current state of the collection of objects that satisfy the following constraint", and then to choose an identifier that is consistent with this resource.
Most programmers get by with studying a few things, then learning the rest by asking people nearby. Which means that a lot of the practical "knowledge" that people have comes from an oral tradition; the story changes each time a new person tells it, and it gets confused with other things.
In the case of REST, the distortion got to a point where the people who knew the original story started looking for a new name to use, just to be able to reintroduce the original ideas.