# Where to put pagination links for included collections

**URL:** <https://discuss.jsonapi.org/t/where-to-put-pagination-links-for-included-collections/2885>\
**Category:** Uncategorized\
**Created:** [July 20, 2024, 1:35pm UTC](https://discuss.jsonapi.org/t/where-to-put-pagination-links-for-included-collections/2885 "2024-07-20T13:35:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerry87](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/jerry87/32/887_2.png) [@Jerry87](https://discuss.jsonapi.org/u/Jerry87)\
**Post date:** [July 20, 2024, 1:35pm UTC](https://discuss.jsonapi.org/t/where-to-put-pagination-links-for-included-collections/2885/1 "2024-07-20T13:35:11Z")

</div>

Regarding pagination links, the specification says:

> Pagination links MUST appear in the links object that corresponds to a collection. To paginate the primary data, supply pagination links in the top-level `links` object. To paginate an included collection returned in a compound document, supply pagination links in the corresponding links object.

But I´m confused about the included-collection part. What does “corresponding” refer to? Does it refer to the links object of the relationship object of the included collection?

That would make sence to me. But in this case, wouldn´t it violate the following?

> Any pagination links in a relationship object MUST paginate the relationship data, not the related resources.

Thanks for clarification!

---

<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:** [July 24, 2024, 9:47pm UTC](https://discuss.jsonapi.org/t/where-to-put-pagination-links-for-included-collections/2885/2 "2024-07-24T21:47:25Z")

</div>

The solution is using a relationship link with the `include` query parameter as the pagination links within a relationship object:

> Furthermore, related resources can be requested from a relationship endpoint:
> 
> ```auto
> GET /articles/1/relationships/comments?include=comments.author HTTP/1.1
> Accept: application/vnd.api+json
> 
> ```
> 
> In this case, the primary data would be a collection of resource identifier objects that represent linkage to comments for an article, while the full comments and comment authors would be returned as included data.

But I agree that this is far from being obvious. I think an explanation in the spec itself would be helpful. I created a GitHub issue to track it: [Clarify pagination for included resources · Issue #1752 · json-api/json-api · GitHub](https://github.com/json-api/json-api/issues/1752)
