Question: I have 2 resources User and Album. An user has a list of albums. To get albums there are 2 REST API.

1. `user/{userId}/albums/{albumId}` gets album by albumId. If not found returns 404
2. `user/{userId}/albums` gets all albums by userId. In this case, if a user has no albums, what should be the status code 204 or 404?

Answer: 
Let me give my 2 cents on this. I hope you already know the difference between 404 vs 204.
The scenario i would prefer to use each status code are :

**404 Status Code**

404 means that the Resource not found or doesn't exist or URL is invalid

For example

```
GET : https://api.myapp.io/product/product_id_123
GET : https://api.myapp.io/image/nokia.jpg

```

If the single product / resource item doesn't exist in database or in resource folder, that means the resource of this URL is invalid so we have to throw 404 and Search Engines like Google & bing will not going to cache the result and will not retry again the next day for fresh content.

**204 Status Code**

204 means that the URL is valid and Server has successfully did the execution but it has no data to return.

For example

```
GET : https://api.myapp.io/product/search?keyword=nokia

```

If there is no data matched (single or multiple) for the keyword in database to return back the results, then throw 204 because there is no data to return but the URL is still valid and Search Engines like Google & bing will retry again the next day for fresh content because for them it is not invalid url and when you retry the next day there might be some data which matches the query.
I agree with the responses, but I think is 204 or 200, it depends of your response when the album list is empty.

If you will return a empty array, the return it with 200 code, if you prefer to don't return anything, then the right one will be 204. (I prefer a 200 with empty list)

Only use 404 with a resource doesn't existis, if it is a empty list the choose 204 or 200.

Good hacking man!