Skip to content


Repository files navigation

public-data-api CircleCI Test Coverage

Exposes datasets stored in S3-compatible object storage with a light-touch API.

  • Is easily hosted on GOV.UK PaaS
  • Does not use a database
  • Data can be published via
  • Data can be accessed by an API, or downloaded
  • Promotes immutable and versioned datasets
  • Includes GOV.UK Design System-styled documentation, exposed on the same domain as the API itself
  • Department-specific content in the documentation is populated from environment variables
  • Low memory usage even for large datasets - responses are streamed to the client
  • Data is gzipped and transparently uncompressed by clients when possible
  • HTTP Range requests are supported when possible to allow clients to resume interrupted downloads
  • The HTTP Content-Length header is returned when possible to allow clients to estimate download time remaining
  • HTTP Cookies are not used

Running tests

pip install -r requirements_test.txt  # Only required once
./                   # Only required once

Running locally

Most development can be done from tests. However, it can be useful to run the front end of the application locally to work on the documentation. The below results in the documentation being visible at http://localhost:8888/

pip install -r requirements.txt  # Only required once
PORT=8888 \
AWS_S3_ENDPOINT=http://any/ \
DOCS_DEPARTMENT_NAME='Department for International Trade' \
    python3 -m app

Environment variables

Variable Description and examples
AWS_S3_REGION The AWS region of the S3 bucket
AWS_S3_ENDPOINT The URL to the bucket, optionally including a key prefix, and will typically end in a slash.
Supports both path and domain-style bucket-access.
READONLY_AWS_ACCESS_KEY_ID The AWS access key ID that has GetObject, and optionally ListBucket, permissions - used by the API
READONLY_AWS_SECRET_ACCESS_KEY The secret part of the readonly AWS access key
READ_AND_WRITE_AWS_ACCESS_KEY_ID The AWS access key ID that has write permissions on the S3 bucket (for the csv-generating worker)
READ_AND_WRITE_AWS_SECRET_ACCESS_KEY The secret part of the read+write AWS access key
APM_SECRET_TOKEN A secret token to authorize requests to the APM Server.
APM_SERVER_URL The URL of the APM server
ENVIRONMENT The current environment where the application is running
GA_ENDPOINT The endpoint to send analytics info to
GA_TRACKING_ID The unique identifier for the google analytics property

Environment variables used for serving API documentation.

Variable Description and examples
DOCS_DEPARTMENT_NAME The name of the department the data is hosted by
A Government Department
DOCS_SERVICE_NAME The name of this service
Data API
DOCS_GITHUB_REPO_URL The URL for this github repository
DOCS_SECURITY_EMAIL The email address security vulnerabilities should be reported to

The below environment variables are also required, but typically populated by PaaS.

Variable Description and examples
PORT The port for the application to listen on

Permissions and 404s

If the AWS user has the ListBucket permission, 404s are proxied through to the user to aid debugging.


On SIGTERM any in-progress requests will complete before the process exits. At the time of writing PaaS will then forcibly kill the process with SIGKILL if it has not exited within 10 seconds.


The source for the Department for International Trade's Public Data API




Security policy





No releases published


No packages published