Pager Examples

Example: Here's an example of getting the first 110 plays of a game, 15 drives at a time with the plays sorted by their orderSequence (Note: plays makes use of default pagination by not explicitly specifying how they should be paged).

Fields Selection:

{
    id,
    season,
    drives {
        id,
        orderSequence,
        plays {
            id,
            orderSequence
        }
    }
}

Query:

{
    "drives": {
        "$take": 15,
        "$skip": 0,
        "$sort": {
            "orderSequence": -1
        },
        "plays": {
            "$query": { // limits the results to the first 110 plays
                "orderSequence": {
                    "$lte": 110
                }
            },
            "$sort": {
                "orderSequence": -1
            }
        }
    }
}

Request:

https://<domain>/v1/games/2e550c17-631b-4536-bdb3-e974449c21f9?fs={id,season,drives{id,orderSequence,plays{id,orderSequence}}}&s={"drives":{"$take":15,"$skip":0,"$sort"{"orderSequence":-1},"plays":{"$query":{"orderSequence":{"$lte":110}},"$sort":{"orderSequence":-1}}}}

Response payload (for the first link):

{
    "id": "2e550c17-631b-4536-bdb3-e974449c21f9",
    "season": 2015,
    "drives": {
        "pager": {
            "previous": null,
            "self": "https://<domain>/v1/games/2e550c17-631b-4536-bdb3-e974449c21f9/drives?fs={id,season,drives{id,orderSequence,plays{id,orderSequence}}}&s={"drives":{"$take":15,"$skip":0,"$sort"{"orderSequence":-1},"plays":{"$query":{"orderSequence":{"$lte":110}},"$sort":{"orderSequence":-1}}}}",
            "next": "https://<domain>/v1/games/2e550c17-631b-4536-bdb3-e974449c21f9/drives?fs={id,season,drives{id,orderSequence,plays{id,orderSequence}}}&s={"drives":{"$take":15,"$skip":15,"$sort"{"orderSequence":-1},"plays":{"$query":{"orderSequence":{"$lte":110}},"$sort":{"orderSequence":-1}}}}",
            "limit": 15,
            "offset": 0,
            "total": 23,
            "sort": {"orderSequence":-1}
        },
        "data": [
            {
                "id": "1ac053bd-b529-464c-b4d4-499b7fe455c7",
                "orderSequence": 1,
                "plays": {
                    "pager": {
                        "previous": null,
                        "self": "https://<domain>/v1/games/2e550c17-631b-4536-bdb3-e974449c21f9/drives/1ac053bd-b529-464c-b4d4-499b7fe455c7/plays?fs={id,orderSequence}&s={"$sort":{"orderSequence":-1},"$take":10,"$skip":0}}",
                        "next": "https://<domain>/v1/games/2e550c17-631b-4536-bdb3-e974449c21f9/drives/1ac053bd-b529-464c-b4d4-499b7fe455c7/plays?fs={id,orderSequence}&s={"$sort":{"orderSequence":-1},"$take":10,"$skip":10}}",
                        "limit": 10,
                        "offset": 0,
                        "total": 12,
                        "sort": {"orderSequence":-1}
                    },
                    "data": [
                        {
                            "id": "867a83c6-6db7-4150-9e86-69a29293c2f9",
                            "orderSequence": "1"
                        },
                        ...
                        {
                            "id": "aab0c8c2-ce8b-4833-aea8-e00e8ac77fac",
                            "orderSequence": "10"
                        }
                    ]
                }
            },
            {
                "id": "c2a5d5ee-f06c-4587-a703-7cb9d8d2e567",
                "orderSequence": 2,
                "plays": {
                    "pager": {
                        "previous": null,
                        "self": "https://<domain>/v1/games/2e550c17-631b-4536-bdb3-e974449c21f9/drives/c2a5d5ee-f06c-4587-a703-7cb9d8d2e567/plays?fs={id,orderSequence}&s={"$sort":{"orderSequence":-1},"$take":0,"$skip":10}}",
                        "next": null,
                        "limit": 10,
                        "offset": 0,
                        "total": 4,
                        "sort": {"orderSequence":-1}
                     },
                    "data": [
                        {
                            "id": "f38dd425-b5b0-4a5b-80ff-bfbf24d0c716",
                            "orderSequence": "13"
                        },
                        ...
                        {
                            "id": "35b476b7-feca-429f-88b1-57acc6d450b8",
                            "orderSequence": "17"
                        }
                    ]
                }
            },
            ...
            ...
            ...
            ...
            {
                "id": "5ecee568-1ef2-404b-9ad7-0e20db518247",
                "orderSequence": 15,
                "plays": {
                    "pager": {
                        "previous": null,
                        "self": "https://<domain>/v1/games/2e550c17-631b-4536-bdb3-e974449c21f9/drives/5ecee568-1ef2-404b-9ad7-0e20db518247/plays?fs={id,orderSequence}&s={"$sort":{"orderSequence":-1},"$take":0,"$skip":10}}",
                        "next": null,
                        "limit": 10,
                        "offset": 0,
                        "total" : 6,
                        "sort" : {"orderSequence":-1}
                     },
                    "data": [
                        {
                            "id": "ae721c27-9c23-44c6-8597-ede18467b11d",
                            "orderSequence": "62"
                        },
                        ...
                        {
                            "id": "6090263b-9a63-46b3-91e4-d65c07bdacc5",
                            "orderSequence": "68"
                        }
                    ]
                }
            }
        ]
    }
}

Example: Here's an example of getting 25 videos related to the Broncos, skipping the first 5. The related games associated with the videos are sorted according to season, when present, paged 2 at a time, skipping the first two.

Fields Selection:

{
    id,
    type,
    title,
    related {
        games {
            id
        },
        teams {
            abbr
        },
        persons {
            displayName
        }
    }
}

Query:

{
    "video": {
        "$take": 25,
        "$skip": 5,
        "related": {
            "$query": {
                "teams": {
                    "abbr": "DEN"
                }
            },
            "games": {
                "$take": 2,
                "$skip": 2,
                "$sort": {
                    "season": 1
                }
            }
        }
    }
}

Request:

https://<domain>/v1/videos?fs={id,type,title,related{games{id},teams{abbr},persons{displayName}}}&s={"video":{"$take":25,"$skip":5,"related":{"$query":{"teams":{"abbr":"DEN"}},"games":{"$take":2,"$skip":2,"$sort":{"season":1}}}}}

Response payload:

{
    "pager": {
        "previous": null,
        "self": "https://<domain>/v1/videos?fs={id,type,title,related{games{id},teams{abbr},persons{displayName}}}&s={"video":{"$take":25,"$skip":5,"related":{"$query":{"teams":{"abbr":"DEN"}},"games":{"$take":2,"$skip":2,"$sort":{"season":1}}}}}",
        "next": "https://<domain>/v1/videos?fs={id,type,title,related{games{id},teams{abbr},persons{displayName}}}&s={"video":{"$take":25,"$skip":30,"related":{"$query":{"teams":{"abbr":"DEN"}},"games":{"$take":2,"$skip":2,"$sort":{"season":1}}}}}",
        "limit": 25,
        "offset": 5,
        "total": 121,
        "sort": {"eventOccurredDate": -1}
    },
    "data": [
        {
            "id": "be2fe5da-2309-4321-9719-a2c596e3acf3",
            "type": "VIDEO",
            "title": "This date in Broncos history: March 11th",
            "related": {
                "games": {
                    "pager": {
                        "previous": "https://<domain>/v1/videos/be2fe5da-2309-4321-9719-a2c596e3acf3/related/games?fs={games{id}}&s={"$take":2,"$skip":0,"$sort":{"season":1}}",
                        "self": "https://<domain>/v1/videos/be2fe5da-2309-4321-9719-a2c596e3acf3/related/games?fs={games{id}}&s={"$take":2,"$skip":2,"$sort":{"season":1}}",
                        "next": null,
                        "limit": 2,
                        "offset": 2,
                        "total": 4,
                        "sort": {"season": 1}
                    }
                    "data": [
                        {
                            "id": "e4f31b1e-b31b-4643-95b3-60427dc1eab3",
                            "season": 1992
                        },
                        {
                            "id": "9e896030-b763-43e2-8842-a13d343a1ae7",
                            "season": 1996
                        }
                    ]
                },
                "teams" {
                    "pager": {
                        "previous": null,
                        "self": "https://<domain>/v1/videos/be2fe5da-2309-4321-9719-a2c596e3acf3/related/teams?fs={teams{abbr}}&s={"$take":10,"$skip":0}",
                        "next": null,
                        "limit": 10,
                        "offset": 0,
                        "total": 2,
                        "sort": {"fullName": 1}
                    },
                    "data": [
                        {
                            "abbr": "DEN"
                        },
                        {
                            "abbr": "OAK"
                        }
                    ]
                },
                "persons" {
                    "pager": {
                        "previous": null,
                        "self": "https://<domain>/v1/videos/be2fe5da-2309-4321-9719-a2c596e3acf3/related/persons?fs={persons{displayName}}&s={"$take":10,"$skip":0}",
                        "next": "https://<domain>/v1/videos/be2fe5da-2309-4321-9719-a2c596e3acf3/related/persons?fs={persons{displayName}}&s={"$take":10,"$skip":10}",
                        "limit": 10,
                        "offset": 0,
                        "total": 14,
                        "sort": {"lastName": 1}
                    },
                    "data": [
                        {
                            "displayName": "John Elway"
                        },
                        ...
                    ]
                }
            }
        },
        ...
    ]
}