Query a data set (GET)
Query a data set using a GET request, returning the filtered results.
Note that there is a POST variant of this endpoint which provides a more complete set
of querying functionality. The GET variant is only recommended for initial exploratory
testing or simple queries that do not need advanced functionality.
Unlike the POST variant, this endpoint does not allow condition clauses (and, or, not)
and consequently cannot express more complex queries. Use the POST variant instead for these
types of queries.
Indicators
The indicators query parameter is required and at least one indicator must be specified.
Each indicator should be a string containing the indicator ID e.g. 4xbOu, 8g1RI.
Filters
The filters query parameter is used to filter by other filter options (not locations,
geographic levels or time periods).
Each filter should be a string containing the required filter option ID e.g. z4FQE, DcQeg.
Geographic levels
The geographicLevels query parameter is used to filter results by geographic level.
The geographic levels are specified as codes, and can be one of the following:
EDA- English devolved areaINST- InstitutionLA- Local authorityLAD- Local authority districtLEP- Local enterprise partnershipLSIP- Local skills improvement plan areaMCA- Mayoral combined authorityMAT- MATNAT- NationalOA- Opportunity areaPA- Planning areaPCON- Parliamentary constituencyPROV- ProviderREG- RegionalRSC- RSC regionSCH- SchoolSPON- SponsorWARD- Ward
Locations
The locations query parameter is used to filter results by location.
The locations should be strings formatted like {level}|{property}|{value} where:
{level}is the location’s level code (e.g.NAT,REG,LA){property}is the name of the identifying property to match on (e.g.id,code,urn`){value}is the value for the property to match
An ID or a code can be used to identify a location, with the following differences:
- IDs only match a single location
- Codes may match multiple locations
Whilst codes are generally unique to a single location, they can be used for multiple locations. This may match more results than you expect so it’s recommended to use IDs where possible.
Examples
LA|code|E08000019matches any local authority with codeE08000019REG|id|6bQgZmatches any region with ID6bQgZSCH|urn|140821matches any school with URN140821
Time periods
The timePeriods query parameter is used to filter results by time period.
The time periods should be strings formatted like {period}|{code} where:
periodis the time period or range (e.g.2020or2020/2021)codeis the code identifying the time period type (e.g.AY,CY,M1,W20)
The period should be a single year like 2020, or a range like 2020/2021.
Currently, only years (or year ranges) are supported.
Some time period types span two years e.g. financial year part 2 (P2), or may fall in a
latter year e.g. academic year summer term (T3). For these types, a singular year period
like 2020 is considered as 2020/2021.
For example, a period value of 2020 is applicable to the following time periods:
- 2020 calendar year
- 2020/2021 academic year
- 2020/2021 financial year part 2 (October to March)
- 2020/2021 academic year’s summer term
If you wish to be more explicit, you may use a range for the period e.g. 2020/2021.
However, a range cannot be used with time period types which only span a single year,
for example, 2020/21 cannot be used with CY, M or W codes.
Examples
2020|AYis the 2020/21 academic year2021|FYis the 2021/22 financial year2020|T3is the 2020/21 academic year’s summer term2020|P2is the 2020/21 financial year part 2 (October to March)2020|CYis the 2020 calendar year2020|W32is 2020 week 322020/2021|AYis the 2020/21 academic year2021/2022|FYis the 2021/22 financial year
Sorts
The sorts query parameter is used to sort the results.
Sorts are applied in the order they are provided and should be strings
formatted like {field}|{direction} where:
fieldis the name of the field to sort e.g.timePerioddirectionis the direction to sort in e.g. ascending (Asc) or descending (Desc)
The field can be one of the following:
timePeriodto sort by time periodgeographicLevelto sort by the geographic level of the datalocation|{level}to sort by locations in a geographic level where{level}is the level code (e.g.REG,LA)filter|{id}to sort by the options in a filter where{id}is the filter ID (e.g.3RxWP)indicator|{id}to sort by the values in a indicator where{id}is the indicator ID (e.g.6VfPgZ)
Examples
timePeriod|Descsorts by time period in descending ordergeographicLevel|Ascsorts by geographic level in ascending orderlocation|REG|Ascsorts by regions in ascending orderfilter|3RxWP|Descsorts by options in filter3RxWPin descending orderindicator|7a1dk|Ascsorts by values in indicator7a1dkin ascending order
The URL for this endpoint is:
GET https://dev.statistics.api.education.gov.uk/api/v{version}/data-sets/{dataSetId}/query
Parameters
Path parameters
The following parameters will need to be substituted into the URL path.
| Parameter | Type | Required | Description |
|---|---|---|---|
dataSetId |
string | true |
The ID of the data set. |
version |
string | true |
The requested API version Defaults to: |
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
dataSetVersion |
string | false |
The version of the data set to use e.g. 2.0, 1.1, etc. |
filters.in |
array (string) | false |
Filter the results to have a filter option matching at least one of these IDs. |
filters.notIn |
array (string) | false |
Filter the results to not have a filter option matching any of these IDs. |
filters.eq |
string | false |
Filter the results to have a filter option matching this ID. |
filters.notEq |
string | false |
Filter the results to not have a filter option matching this ID. |
geographicLevels.in |
array (GeographicLevelCode) | false |
Filter the results to be in one of these geographic levels. |
geographicLevels.notIn |
array (GeographicLevelCode) | false |
Filter the results to not be in one of these geographic levels. |
geographicLevels.eq |
GeographicLevelCode | false |
Filter the results to be in this geographic level. |
geographicLevels.notEq |
GeographicLevelCode | false |
Filter the results to not be in this geographic level. |
locations.eq |
string | false |
Filter the results to be in this location. |
locations.notEq |
string | false |
Filter the results to not be in this location. |
locations.in |
array (string) | false |
Filter the results to be in one of these locations. |
locations.notIn |
array (string) | false |
Filter the results not to be in one of these locations. |
timePeriods.eq |
string | false |
Filter the results to be in this time period. |
timePeriods.notEq |
string | false |
Filter the results to not be in this time period. |
timePeriods.in |
array (string) | false |
Filter the results to be in one of these time periods. |
timePeriods.notIn |
array (string) | false |
Filter the results to not be in one of these time periods. |
timePeriods.gt |
string | false |
Filter the results to be in a time period that is chronologically greater than the one specified. |
timePeriods.gte |
string | false |
Filter the results to be in a time period that is chronologically greater than or equal to the one specified. |
timePeriods.lt |
string | false |
Filter the results to be in a time period that is chronologically less than the one specified. |
timePeriods.lte |
string | false |
Filter the results to be in a time period that is chronologically less than or equal to the one specified. |
indicators |
array (string) | true |
The IDs of indicators to return values for. |
sorts |
array (string) | false |
The sorts to apply to the results. Sorts at the start of the list will be applied first. By default, results are sorted by time period in descending order. |
debug |
boolean | false |
Enable debug mode. Results will be formatted with human-readable labels to assist in identification. This should not be enabled in a production environment. |
page |
integer | false |
The page of results to fetch. Defaults to: Validation constraints:
|
pageSize |
integer | false |
The maximum number of results per page. Defaults to: Validation constraints:
|
Example request
To illustrate how to use this API endpoint, we have provided some samples below in various languages.
cURL
curl -X GET https://dev.statistics.api.education.gov.uk/api/v{version}/data-sets/{dataSetId}/query
JavaScript
const url = 'https://dev.statistics.api.education.gov.uk/api/v{version}/data-sets/{dataSetId}/query';
const response = await fetch(url, {
method: 'GET',
});
console.log(response.json());
Python
import requests
url = 'https://dev.statistics.api.education.gov.uk/api/v{version}/data-sets/{dataSetId}/query'
response = requests.get(url)
print(response.text)
R
library(httr)
url <- "https://dev.statistics.api.education.gov.uk/api/v{version}/data-sets/{dataSetId}/query"
response <- GET(url)
output <- content(response)
Responses
| Status | Description | Media Type | Schema |
|---|---|---|---|
| 200 | The paginated list of query results. |
application/json | DataSetQueryPaginatedResultsViewModel |
| 400 | Bad Request |
application/json | ValidationProblemViewModel |
| 403 | Forbidden |
application/json | ProblemDetailsViewModel |
| 404 | Not Found |
application/json | ProblemDetailsViewModel |
Example successful response
{
"paging": {
"page": 1,
"pageSize": 20,
"totalResults": 60,
"totalPages": 3
},
"results": [
{
"timePeriod": {
"code": "AYQ1",
"period": "2020/2021"
},
"geographicLevel": "NAT",
"locations": {
"NAT": "04bTr",
"REG": "4veOu",
"LA": "owqlK"
},
"filters": {
"ups2K": "n0WqP",
"j51wV": "AnZsi",
"hAkBQ": "dvB4z"
},
"values": {
"wLcft": "23593018",
"4S8Ou": "50.342",
"9kVFg": "25369172"
}
}
],
"warnings": [
{
"message": "There are no results.",
"path": "results",
"code": "NoResults",
"detail": {
"total": 0
}
}
]
}