Skip to content
KindTechUKPublic

About

CLI tool for searching, viewing, and fetching FOI requests from WhatDoTheyKnow.com

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

20 Commits

Folders and files

open-foi

Search Freedom of Information requests on WhatDoTheyKnow from the command line, and save what you find.

Docs · Questions and ideas · Contribute

Try it

You need uv and Python 3.11 or newer.

uv tool install "git+https://github.com/KindTechUK/open-foi"
foi search "hate crime" --authority essex_police --max-pages 1 --format summary

The start of what it printed on 29 November 2026:

Found 19 requests (25 events, 1 pages)

  1. daily hate crime counts (race and religion), September 2025 to October 2026
     Authority: Essex Police | Status: waiting_response | Days: 0
     https://www.whatdotheyknow.com/request/daily_hate_crime_counts_race_and_2

  2. East and Southeast Asian (ESEA) Hate Crimes/Incidents Data 2020-25
     Authority: Essex Police | Status: waiting_response | Days: 174
     https://www.whatdotheyknow.com/request/east_and_southeast_asian_esea_ha_54

Open a link to read the request and its replies on WhatDoTheyKnow.

About

A command-line tool for searching Freedom of Information requests on WhatDoTheyKnow.com, the UK's primary FOI platform powered by Alaveteli.

Built for researchers, journalists, and anyone working with FOI data at scale.

Features

  • Search FOI requests with advanced filters (status, authority, filetype, tags)
  • Structured output with requests as primary entities and nested event timelines
  • Time tracking — days between events, total request duration
  • Export to JSON, CSV, or plain text
  • Caching — SQLite-backed response cache to avoid redundant API calls
  • Agent-friendly — JSON output works natively with Claude Code, jq, and other tools

open-foi is a feed-API client only. Each result includes the full request URL on WhatDoTheyKnow — open it in your browser to read the correspondence and download any attachments.

Installation

Requires Python 3.11+.

# Install from GitHub
uv tool install "git+https://github.com/KindTechUK/open-foi"

# Or clone and install locally
git clone https://github.com/KindTechUK/open-foi.git
cd open-foi
uv tool install .

Quick start

Search FOI requests

# Search for ESEA hate crime FOI requests
foi search "east and southeast asian hate crimes"

# Filter by status
foi search "ESEA hate crimes" --status successful

# Filter by authority
foi search "NHS funding" --authority department_of_health_and_social_care

# Export to CSV
foi search "ESEA hate crimes" --output results.csv

# Plain text summary
foi search "ESEA hate crimes" --format summary

Output structure

Search results are structured as deduplicated requests with nested event timelines:

{
  "query": "ESEA hate crimes",
  "total_requests": 130,
  "total_events": 255,
  "requests": [
    {
      "title": "East and Southeast Asian (ESEA) Hate Crimes/Incidents Data 2020-25",
      "url": "https://www.whatdotheyknow.com/request/east_and_southeast_asian_esea_ha_63",
      "authority": "Nottinghamshire Police",
      "status": "successful",
      "total_days": 184,
      "events": [
        { "type": "sent", "date": "2025-06-01", "status": "waiting_response", "days_since_previous": null },
        { "type": "response", "date": "2025-12-03", "status": "successful", "days_since_previous": 185 }
      ]
    }
  ]
}

The url on each request is the canonical WhatDoTheyKnow page. Open it in your browser to read the full correspondence and download attachments.

Other commands

# List/search public authorities
foi authorities --search "police"

# Cache management
foi cache stats
foi cache clear

# Verbose logging (debug)
foi -v search "NHS"

Search operators

WhatDoTheyKnow supports a rich query language:

Flag Search operator Example
--status latest_status: successful, rejected, waiting_response
--authority requested_from: home_office, kent_police
--user requested_by: julian_todd
--filetype filetype: pdf, xlsx, csv
--tag tag: police, environment

You can also use these operators directly in the query string:

foi search "climate change filetype:pdf latest_status:successful"

How it works

open-foi uses WhatDoTheyKnow's JSON feed endpoints (/feed/search/*.json) with ?page=N pagination to retrieve all results. No authentication required. Rate-limited to 1 request/second by default.

For everything beyond search — full correspondence text, attachments — open the request URL in your browser.

Configuration

Optional config file at ~/.config/open-foi/config.toml:

rate_limit = 1.0          # Seconds between API requests
timeout = 30.0             # HTTP timeout
default_format = "json"    # json, summary, or csv

[cache]
enabled = true
ttl = 3600                 # Cache TTL in seconds

Responsible use

This tool accesses publicly available FOI data from WhatDoTheyKnow.com, a service run by mySociety, a UK charity dedicated to transparency and open data.

  • FOI responses are typically Crown Copyright, reusable under the Open Government Licence
  • Rate limiting is enforced by default to be respectful of server resources
  • Feed API access uses officially documented endpoints

Please use this tool responsibly. If you plan to make large-scale or high-frequency requests, consider reaching out to mySociety first.

Development

git clone https://github.com/KindTechUK/open-foi.git
cd open-foi
uv venv && uv pip install -e ".[dev]"

# Run tests
uv run pytest tests/ -v

# Lint
uv run ruff check src/ tests/

License

Apache-2.0

Acknowledgements

  • mySociety for building and maintaining WhatDoTheyKnow
  • Alaveteli — the open-source FOI platform
  • FOI data published on WhatDoTheyKnow is contributed by its users and the public authorities that respond

About

CLI tool for searching, viewing, and fetching FOI requests from WhatDoTheyKnow.com

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages