# Best way to handle nested filtering?

**URL:** <https://discuss.jsonapi.org/t/best-way-to-handle-nested-filtering/3027>\
**Category:** Uncategorized\
**Created:** [May 5, 2025, 10:47am UTC](https://discuss.jsonapi.org/t/best-way-to-handle-nested-filtering/3027 "2025-05-05T10:47:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathew78](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/mathew78/32/935_2.png) [@Mathew78](https://discuss.jsonapi.org/u/Mathew78)\
**Post date:** [May 5, 2025, 10:47am UTC](https://discuss.jsonapi.org/t/best-way-to-handle-nested-filtering/3027/1 "2025-05-05T10:47:28Z")

</div>

Hi everyone,  
I’m building an API using JSON:API spec and I’m a bit stuck on how to properly implement filtering on a nested relationship (e.g., /articles?filter[comments.author.name]=John).  
Is this kind of deep filtering considered valid, or should it be handled differently?

Appreciate any advice!

---

<div class="post-metadata">

**Author:** ![jelhan](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/jelhan/32/822_2.png) [@jelhan](https://discuss.jsonapi.org/u/jelhan)\
**Post date:** [May 9, 2025, 10:06am UTC](https://discuss.jsonapi.org/t/best-way-to-handle-nested-filtering/3027/2 "2025-05-09T10:06:24Z")

</div>

The JSON:API specification is agnostic about filtering. It only defines that `filter` query parameter family should be used for it. How filtering is implemented is up to each implementation. It may be specified by a profile.

Filtering a collection based on attributes of related resources (or their existence) is a common use case. Reusing the concept of relationship paths defined by the specification for the `include` query parameter is a good choice in my opinion. Doing so ensures that the filtering semantics are well aligned with the rest of the specification.

I think someone should formalize that strategy as a profile at some point in time.
