# Pagination & Filtering, what about the links?

**URL:** <https://discuss.jsonapi.org/t/pagination-filtering-what-about-the-links/2291>\
**Category:** Uncategorized\
**Created:** [August 12, 2021, 2:41pm UTC](https://discuss.jsonapi.org/t/pagination-filtering-what-about-the-links/2291 "2021-08-12T14:41:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![evdelst](https://avatars.discourse-cdn.com/v4/letter/e/958977/32.png) [@evdelst](https://discuss.jsonapi.org/u/evdelst)\
**Post date:** [August 12, 2021, 2:41pm UTC](https://discuss.jsonapi.org/t/pagination-filtering-what-about-the-links/2291/1 "2021-08-12T14:41:19Z")

</div>

Hi,  
I have a question about what the contents of the ‘links’ should be when a combination of pagination and filtering is used.

Concrete: should the ‘next’ link also contain the filter parameters, or just (for example) ‘page[size]=10&page[number]=2’?  
If the filter parameters are not part of the link, I guess they cannot be used to navigate through a filtered collection…

---

<div class="post-metadata">

**Author:** ![timothy.stone](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/timothy.stone/32/750_2.png) [@timothy.stone](https://discuss.jsonapi.org/u/timothy.stone)\
**Post date:** [August 12, 2021, 5:31pm UTC](https://discuss.jsonapi.org/t/pagination-filtering-what-about-the-links/2291/2 "2021-08-12T17:31:59Z")

</div>

I think you are correct in this reading of the pagination and the general indifference of JSON:api on filtering, see 6.7 Filtering (using my specification reference, [see PR](https://github.com/json-api/json-api/pull/1574)). Or just look up Filtering (not as easy IMHO 🙂 )

The `filter` query parameter is reserved for this. It becomes a bit harder using a POST and a request body for filtering though (which is a proposal my team is looking to use).

There are a number of [discussions here about filtering strategies](https://discuss.jsonapi.org/search?q=filtering) that may be of interest as well.

I’d be interested to know what you come up with too!

---

<div class="post-metadata">

**Author:** ![fdrake](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/fdrake/32/654_2.png) [@fdrake](https://discuss.jsonapi.org/u/fdrake)\
**Post date:** [August 12, 2021, 5:40pm UTC](https://discuss.jsonapi.org/t/pagination-filtering-what-about-the-links/2291/3 "2021-08-12T17:40:34Z")

</div>

The collection you are paginating is defined by the collection you’re addressing by the URL _and_ any non-pagination parameters provided (`filter`, `sort`, or non-standard parameters`). So the pagination links present in the top-level `links` for a collection response should include all the required parameters.

In my implementation, I copy all the non-pagination parameters into all the links in my response rendering library, so it’s always handled the same way. The pagination support is responsible for providing any `page[...]` parameters needed for each of the links.

-Fred

---

<div class="post-metadata">

**Author:** ![evdelst](https://avatars.discourse-cdn.com/v4/letter/e/958977/32.png) [@evdelst](https://discuss.jsonapi.org/u/evdelst)\
**Post date:** [August 13, 2021, 7:32am UTC](https://discuss.jsonapi.org/t/pagination-filtering-what-about-the-links/2291/4 "2021-08-13T07:32:42Z")

</div>

Thank you for the suggestions.  
I will request the filter parameters to be copied to the pagination links (I am consuming this API).  
This makes the most sense to me.
