Gist cf029c23fefdf183ae507ea5205298dc
✓ Published0🌍 Public
RRobinL
Last edited Feb 10, 2019
Created on Feb 10, 2019
This example demonstrates how to query the UK Office for National Statistics (ONS) beta API to retrieve filtered mid-year population estimates. The Python script constructs a JSON request specifying dimensions like age (0-89), sex, and time (2015-2017), then submits it via `requests.post` to the `/v1/filters` endpoint. The process illustrates that omitting a required `geography` dimension causes the request to fail, while including it allows the script to poll the returned `filter_output` link and obtain a CSV download URL. The code uses `requests`, `json`, and `pandas` to manage the API interaction and data retrieval.
AI-generated description