# Should you return all resources by default (when no filter specified)

**URL:** <https://discuss.jsonapi.org/t/should-you-return-all-resources-by-default-when-no-filter-specified/1233>\
**Category:** Uncategorized\
**Created:** [March 13, 2018, 3:13pm UTC](https://discuss.jsonapi.org/t/should-you-return-all-resources-by-default-when-no-filter-specified/1233 "2018-03-13T15:13:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SierraRomeo](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@SierraRomeo](https://discuss.jsonapi.org/u/SierraRomeo)\
**Post date:** [March 13, 2018, 3:13pm UTC](https://discuss.jsonapi.org/t/should-you-return-all-resources-by-default-when-no-filter-specified/1233/1 "2018-03-13T15:13:15Z")

</div>

Hi there,

Let’s say I use a soft delete strategy with a status which could be published or trashed.

By default (without specifying a filter) I would like to return all posts which are published.  
Is that allowed or should I call /posts?filter[status]=published ?

I would prefer to just get /posts, and have only the published ones, and then get /posts?filter[status]=trashed to get only the trashed ones, or get /posts?filter[status]=all to get everything.

I cannot find an answer to this in the spec.  
What do you think?

Thanx

---

<div class="post-metadata">

**Author:** ![michaelhibay](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/michaelhibay/32/405_2.png) [@michaelhibay](https://discuss.jsonapi.org/u/michaelhibay)\
**Post date:** [March 13, 2018, 9:06pm UTC](https://discuss.jsonapi.org/t/should-you-return-all-resources-by-default-when-no-filter-specified/1233/2 "2018-03-13T21:06:12Z")

</div>

I would be wary of doing things which are not immediately intuitive to the API consumer. You are under no responsibility to display any resources you don’t want to, but I would make sure you properly convey this behavior to consumers otherwise you will have a lot of confused and annoyed developers on your hands.

Unless you have a solid, very apparent, means to show this (like vocabulary driven hypermedia) and all clients are using a discovery mechanism, I would suggest instead returning some links to the “root” of each filtered set with the filter strategy.

---

<div class="post-metadata">

**Author:** ![SierraRomeo](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@SierraRomeo](https://discuss.jsonapi.org/u/SierraRomeo)\
**Post date:** [March 21, 2018, 9:36am UTC](https://discuss.jsonapi.org/t/should-you-return-all-resources-by-default-when-no-filter-specified/1233/3 "2018-03-21T09:36:13Z")

</div>

Hi Michael, thanx for getting back to me.

The reason behind this is that 99% of the time, the API should return only resources that are published.  
So I believe that **/posts** by default should return the same thing as **/posts?filter[status]=published**

I don’t want 99% of the calls to the API to include a filter that could be considered default and thus avoided.

For the 1%, the call could be **?filter[status]=trashed** or **?filter[status]=all**

I don’t see any problems in doing so but you are right, I have to convey the information to the developers.

But I’m curious, what do you mean by returning some links to the “root” of each filtered set with the filter strategy.

---

<div class="post-metadata">

**Author:** ![michaelhibay](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/michaelhibay/32/405_2.png) [@michaelhibay](https://discuss.jsonapi.org/u/michaelhibay)\
**Post date:** [June 25, 2018, 7:59pm UTC](https://discuss.jsonapi.org/t/should-you-return-all-resources-by-default-when-no-filter-specified/1233/4 "2018-06-25T19:59:10Z")

</div>

Wow, apologies for dropping the ball on this response. I’m not sure if this will help so long after you’re question but I’ll do it anyway just in case.

```auto
GET /posts
200 OK
{
  "links":{
    "published":"http://example.org/posts?filter[status]=published",
    "trashed":"http://example.org/posts?filter[status]=trashed",
    "all":"http://example.org/posts?filter[status]=all"
  }
}

```
