Skip to content
This repository was archived by the owner on Mar 24, 2021. It is now read-only.

Read API example responses

Rob Young edited this page Feb 4, 2014 · 6 revisions

Example responses for grouping queries

// /licensing\
// ?group_by=authorityUrlSlug\

{
    "bucket": "licensing",
    "query": {
        "group_by": "authorityUrlSlug"
    },
    "data": [
        {
            "authorityUrlSlug": "westminster",
            "_count": 3
        },
        {
            "authorityUrlSlug": "camden",
            "_count": 1
        }
    ]
}

// /licensing\
// ?group_by=authorityUrlSlug\
// &collect=authorityName
// &collect=licenceName

{
    "bucket": "licensing",
    "query": {
        "group_by": "authorityUrlSlug",
        "collect": ["authorityName", "licenceName"]
    },
    "data": [
        {
            "authorityUrlSlug": "westminster",
            "authorityName": ["Westminster"],
            "licenceName": ["Temporary events notice"],
            "_count": 3
        },
        {
            "authorityUrlSlug": "camden",
            "authorityName": ["Camden"],
            "licenceName": ["Temporary events notice"],
            "_count": 1
        }
    ]
}

// /licensing\
// ?group_by=authorityUrlSlug\
// &collect=authorityName
// &collect=licenceName
// &start_at=2013-02-03T00:00:00\
// &end_at=2013-02-10T00:00:00\

{
    "bucket": "licensing",
    "query": {
        "group_by": "authorityUrlSlug",
        "collect": ["authorityName", "licenceName"],
        "start_at": "2013-02-03T00:00:00",
        "end_at": "2013-02-10T00:00:00"
    },
    "data": [
        {
            "authorityUrlSlug": "westminster",
            "authorityName": ["Westminster"],
            "licenceName": ["Temporary events notice"],
            "_count": 3
        },
        {
            "authorityUrlSlug": "camden",
            "authorityName": ["Camden"],
            "licenceName": ["Temporary events notice"],
            "_count": 1
        }
    ]
}

// /licensing\
// ?period=week&start_at=2012-12-03T00:00:00&end_at=2012-12-17T00:00:00

{
    "bucket": "licensing",
    "query": {
        "period": "week",
        "start_at": "2012-12-03T00:00:00+00:00",
        "end_at": "2012-12-17T00:00:00"
    },
    "data": [
        {
            "_start_at": "2012-12-03T00:00:00+00:00",
            "_end_at": "2012-12-10T00:00:00+00:00",
            "_count": 3
        },
        {
            "_start_at": "2012-12-10T00:00:00+00:00",
            "_end_at": "2012-12-17T00:00:00+00:00",
            "_count": 1
        }
    ]
}

// /licensing\
// ?group_by=authorityUrlSlug\
// &filter_by=licenceUrlSlug:temporary-events-notice\
// &start_at=2013-02-03T00:00:00\
// &end_at=2013-02-10T00:00:00\
// &period=week

{
    "bucket": "licensing",
    "query": {
        "group_by": "authorityUrlSlug",
        "filter_by": "licenceUrlSlug:temporary-events-notice",
        "start_at": "2013-02-03T00:00:00",
        "end_at": "2013-02-10T00:00:00",
        "period": "week"
    },
    "data": [
        {
            "authorityUrlSlug": "westminster",
            "values": [
                {
                    "_start_at": "2012-12-03T00:00:00+00:00",
                    "_end_at": "2012-12-10T00:00:00+00:00",
                    "_count": 5
                },
                {
                    "_start_at": "2012-12-10T00:00:00+00:00",
                    "_end_at": "2012-12-17T00:00:00+00:00",
                    "_count": 8
                }
            ]
        },
        {
            "authorityUrlSlug": "camden",
            "values": [
                {
                    "_start_at": "2012-12-03T00:00:00+00:00",
                    "_end_at": "2012-12-10T00:00:00+00:00",
                    "_count": 4
                },
                {
                    "_start_at": "2012-12-10T00:00:00+00:00",
                    "_end_at": "2012-12-17T00:00:00+00:00",
                    "_count": 5
                }
            ]
        }
    ]
}


// /licensing?group_by=authorityUrlSlug\
// &filter_by=licenceUrlSlug:temporary-events-notice\
// &filter_by=type:success\
// &start_at=2013-02-03T00:00:00\
// &end_at=2013-02-10T00:00:00\
// &period=week\
// &collect=authorityName

{
    "bucket": "licensing",
    "query": {
        "group_by": "authorityUrlSlug",
        "filter_by": "licenceUrlSlug:temporary-events-notice",
        "start_at": "2013-02-03T00:00:00",
        "end_at": "2013-02-10T00:00:00",
        "period": "week"
    },
    "data": [
        {
            "authorityUrlSlug": "westminster",
            "authorityName": ["Westminster"],
            "values": [
                {
                    "_start_at": "2012-12-03T00:00:00+00:00",
                    "_end_at": "2012-12-10T00:00:00+00:00",
                    "_count": 5
                },
                {
                    "_start_at": "2012-12-10T00:00:00+00:00",
                    "_end_at": "2012-12-17T00:00:00+00:00",
                    "_count": 8
                }
            ]
        },
        {
            "authorityUrlSlug": "camden",
            "authorityName": ["Camden"],
            "values": [
                {
                    "_start_at": "2012-12-03T00:00:00+00:00",
                    "_end_at": "2012-12-10T00:00:00+00:00",
                    "_count": 4
                },
                {
                    "_start_at": "2012-12-10T00:00:00+00:00",
                    "_end_at": "2012-12-17T00:00:00+00:00",
                    "_count": 5
                }
            ]
        }
    ]
}

// /licensing\
// ?period=week&end_at=2012-12-17T00:00:00&duration=1

{
    "bucket": "licensing",
    "query": {
        "period": "week",
        "start_at": "2012-12-03T00:00:00+00:00",
        "end_at": "2012-12-17T00:00:00"
    },
    "data": [
        {
            "_start_at": "2012-12-03T00:00:00+00:00",
            "_end_at": "2012-12-10T00:00:00+00:00",
            "_count": 3
        },
        {
            "_start_at": "2012-12-10T00:00:00+00:00",
            "_end_at": "2012-12-17T00:00:00+00:00",
            "_count": 1
        }
    ]
}

Notes

  • if the query end date falls inside a period, the read API automatically extends to the full period

Clone this wiki locally