A simple CORS proxy for the Economics Observatory, built with Netlify Functions.
Send GET requests to:
https://eco-cors-proxy.netlify.app/proxy?url=YOUR_ENCODED_URL
- CPI Annual Rate (d7g7):
https://eco-cors-proxy.netlify.app/proxy?url=https://api.ons.gov.uk/timeseries/d7g7/dataset/mm23/data
- CPI Annual Rate (d7g7):
https://eco-cors-proxy.netlify.app/proxy?url=https://api.beta.ons.gov.uk/v1/data?uri=/economy/inflationandpriceindices/timeseries/d7g7/mm23
- GDP Quarter on Quarter Growth (l55o):
https://eco-cors-proxy.netlify.app/proxy?url=https://api.beta.ons.gov.uk/v1/data?uri=/economy/inflationandpriceindices/timeseries/l55o/mm23
- Unemployment Rate (mgsx):
https://eco-cors-proxy.netlify.app/proxy?url=https://api.beta.ons.gov.uk/v1/data?uri=/employmentandlabourmarket/peoplenotinwork/unemployment/timeseries/mgsx/lms
- CPI Annual Rate via ECO ONS API Converter:
https://eco-cors-proxy.netlify.app/proxy?url=https://economicsobservatory.github.io/api/ons.html?url=https://api.ons.gov.uk/timeseries/d7g7/dataset/mm23/data&format=json&data_only=true
- GDP Growth via ECO ONS API Converter:
https://eco-cors-proxy.netlify.app/proxy?url=https://economicsobservatory.github.io/api/ons.html?code=l55o&format=json&data_only=true
- Unemployment Rate via ECO ONS API Converter:
https://eco-cors-proxy.netlify.app/proxy?url=https://economicsobservatory.github.io/api/ons.html?code=mgsx&format=json&data_only=true
Here's an example of how to use the proxy with Vega-Lite:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title": "CPI Annual Rate",
"data": {
"url": "https://eco-cors-proxy.netlify.app/proxy?url=https://economicsobservatory.github.io/api/ons.html?code=d7g7&format=json&data_only=true",
"format": {
"type": "json",
"property": "months"
}
},
"mark": {"type": "line"},
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "value", "type": "quantitative"}
}
}
- Clone the repository:
git clone https://github.com/EconomicsObservatory/cors-proxy.git
cd cors-proxy
- Install dependencies:
npm install
- Install Netlify CLI:
npm install -g netlify-cli
- Test locally:
netlify dev
The proxy is automatically deployed to Netlify when changes are pushed to the main branch.
Current deployment: https://eco-cors-proxy.netlify.app
- Rate limited to prevent abuse
- Only GET requests are supported
- URL must be properly encoded
- Response must be valid JSON
Feel free to open issues or submit pull requests if you find any problems or have suggestions for improvements.
MIT
Next steps:
1. Create the repository on GitHub
2. Push all files
3. Connect to Netlify
4. Deploy
Would you like help with any of these steps?