

API Reference
Site Settings
Version: 4.0
Updated: 14th July 2024
Updated: 14th July 2024
Fetching Site Settings
Site settings includes the ID of topics and mastheads, which are useful when editing datasets.
GET
https://data.website/api/siteHTTP Return Codes
200 | Returns the site settings JSON. |
JSON Reference
/api/site
{
// Used in the browser tab title
"title": "Barnet Open Data",
"mastheads": {
"ons": {
"img": "https://.../office-for-national-statistics--ons-.png",
"title": "Office for National Statistics (ONS)"
},
// [...mastheads are set up through the web interface]
},
"topics": {
"waste-and-recycling": {
"img": "https://.../waste-recycling.png",
"title": "Waste & Recycling"
},
// [...topics are set up through the web interface]
},
// Search sidebar
"searchFilters": [
"topic",
"format",
"tag"
],
"licences": [
// Set up through the web interface
{
"url": "https://.../doc/open-government-licence/version/3/",
"title": "UK Open Government Licence (OGL v3)"
},
// [...]
],
// -- UI Design
// Edit these with caution!
"design": {
// Images & links
"logo": "https://cdn.datapress.cloud/barnet/img/design/brand-logo.png",
"favicon": "https://cdn.datapress.cloud/barnet/img/design/favicon.ico",
"footer": {
"home": {
"img": "https://cdn.datapress.cloud/barnet/img/design/logo_barnet.png",
"url": "https://www.barnet.gov.uk",
"text": "Barnet Council"
}
},
// Google Analytics integration
"googleAnalytics": "UA-..."
}
// -- Site Settings
"customFields": {
// [...set up through the web interface]
},
"id": "mysite", // Immutable
"hostname": "data.website", // Immutable
"https": true, // Immutable
}
Updating the site settings
PATCH
https://data.website/api/siteHTTP Headers
Authorization | API key with administrator permissions. | string | Required |
HTTP Return Codes
200 | Returns the updated site settings JSON. |
400 | Returns a JSON object explaining the error. |
403 | API key does not have administrator permissions. |
Example: Rename a topic
import requests, os, json
api_key = os.getenv("DATAPRESS_API_KEY")
headers = { "Authorization": api_key }
patch = [
{
"op": "replace",
"path": "/topics/waste-and-recycling/title",
"value": "Reduce, Reuse, Recycle"
}
]
url = f"https://data.website/api/site"
# This will submit the patch with the header "Content-Type: application/json"
response = requests.patch(url, json=patch, headers=headers)
print(json.dumps(response.json(), indent=2))
{
// [...full JSON structure...]
"topics": {
"waste-and-recycling": {
"img": "https://.../waste-recycling.png",
"title": "Reduce, Reuse, Recycle"
},
// [...other topics...]
}
}