DataPress logo
API Reference

Site Settings

Version:  4.0
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/site
HTTP Return Codes
200Returns 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/site
HTTP Headers
AuthorizationAPI key with administrator permissions.stringRequired
HTTP Return Codes
200Returns the updated site settings JSON.
400Returns a JSON object explaining the error.
403API 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))