I suggest page[limit]
and page[offset]
.
This is one of the many, many reasons which I constantly say unrelated resources should not ever be included as sub resources in the path. The answer is simple, your related collection should use the canonical URL for the resource related to it, as such all you need to provide is the pagination parameters for the related collection within the link. Paginating the two resources is only in conflict if you have to somehow provide query parameters to paginate them simultaneously, and I’m at a loss to come up with a reason a use case for this.
It is a big example, but look and see how unrelated comment-author
and post
are to each other.
{
"data": [
{
"type": "post",
"id": "1",
"attributes": {
"title": "It's a title.",
"relationships": {
"comment-author": {
"links": {
"self": "http://example.com/articles/1/relationships/comment-author",
"related": "http://example.com/comment?filter[article]=1&page[limit]=50&page[offset]=0"
}
},
"author": {
"links": {
"self": "http://example.com/articles/1/relationships/author",
"related": "http://example.com/people?filter[article]=1"
},
"data": {
"type": "people",
"id": "9"
}
}
}
},
"links": {
"self": "http://example.com/articles/1"
}
},
{
"type": "post",
"id": "2",
"attributes": {
"title": "It's a title.2",
"relationships": {
"comment-author": {
"links": {
"self": "http://example.com/articles/2/relationships/comment-author",
"related": "http://example.com/comment?filter[article]=2&page[limit]=50&page[offset]=0"
}
},
"author": {
"links": {
"self": "http://example.com/articles/2/relationships/author",
"related": "http://example.com/people?filter[article]=2"
},
"data": {
"type": "people",
"id": "9"
}
}
}
},
"links": {
"self": "http://example.com/articles/2/relationships/author"
}
}
],
"included": [
{
"type": "people",
"id": "9",
"attributes": {
"first-name": "Dan",
"last-name": "Gebhardt",
"twitter": "dgeb"
},
"links": {
"self": "http://example.com/people/9"
}
}
],
"links": {
"self": "http://example.com/articles?filter[author]=9",
"first": "http://example.com/articles?filter[author]=9",
"next": "http://example.com/articles?filter[author]=9&page[limit]=50&page[offset]=1",
"last": "http://example.com/articles?filter[author]=9&page[limit]=50&page[offset]=10"
}
}