Skip to main content

A Python package that monitors UK legislation for material changes and sends notifications via email, Slack, or webhook

Project description

uk-reg-monitor

PyPI version

uk-reg-monitor is an open-source Python package that monitors UK employment legislation for material changes on a schedule. It acts as a companion client to the UK Employment Law Change Detector API: you configure which Acts of Parliament to watch and how often to check, and uk-reg-monitor handles the scheduling, calls the API on each cycle, and routes any detected changes to your team via email, Slack, or a generic webhook.

Available on PyPI: https://pypi.org/project/uk-reg-monitor/


Installation

pip install uk-reg-monitor

For development (editable install with test dependencies):

git clone https://github.com/example/uk-reg-monitor.git
cd uk-reg-monitor
pip install -e ".[dev]"

Requires Python 3.9 or later.


Quickstart

Step 1 — Run the setup wizard

uk-reg-monitor init

The wizard guides you through choosing which Acts to monitor, how often to check, and how to receive notifications. It writes config.yaml to your working directory and validates it automatically.

Prefer to configure manually? Create config.yaml by hand:

api:
  base_url: "https://uk-employment-law-change-detector.onrender.com"
  timeout: 30

schedule:
  frequency: "daily"   # hourly | daily | weekly
  time: "08:00"        # HH:MM — used by daily and weekly
  day: "monday"        # day of week — used by weekly only

acts:
  - url: "https://www.legislation.gov.uk/ukpga/1996/18"
    name: "Employment Rights Act 1996"
  - url: "https://www.legislation.gov.uk/ukpga/2010/15"
    name: "Equality Act 2010"
  - url: "https://www.legislation.gov.uk/ukpga/1992/52"
    name: "Trade Union and Labour Relations (Consolidation) Act 1992"

notifications:
  email:
    enabled: false
    smtp_host: "smtp.example.com"
    smtp_port: 587
    use_tls: true
    username: ""
    password: ""
    from_addr: "monitor@example.com"
    to_addrs:
      - "team@example.com"

  slack:
    enabled: false
    webhook_url: ""

  webhook:
    enabled: false
    url: ""
    method: "POST"
    headers:
      Content-Type: "application/json"

Then run uk-reg-monitor validate to check it.

Step 2 — Start the monitor

uk-reg-monitor start

The monitor runs an immediate check on startup, then repeats on the configured schedule. Press Ctrl+C to stop.


CLI Commands

uk-reg-monitor init

Runs the interactive setup wizard. Guides you through choosing Acts, schedule frequency, and notification channels, then writes config.yaml and validates it automatically. Passwords are collected without echoing to the terminal.

uk-reg-monitor init
uk-reg-monitor init --config /path/to/config.yaml

uk-reg-monitor start

Starts the scheduled monitor. Runs an immediate check, then repeats according to schedule.frequency.

uk-reg-monitor start
uk-reg-monitor start --config /path/to/config.yaml
uk-reg-monitor start --verbose

uk-reg-monitor check

Runs a single immediate check across all configured Acts and prints the results to the terminal. Does not start the scheduler.

uk-reg-monitor check
uk-reg-monitor check --config /path/to/config.yaml

uk-reg-monitor validate

Validates config.yaml and prints a summary. Exits with a non-zero code if validation fails. Use this to verify configuration before deploying.

uk-reg-monitor validate
uk-reg-monitor validate --config /path/to/config.yaml

Global flags

Flag Description
--config PATH Path to config.yaml (default: ./config.yaml)
--verbose Enable debug logging

Schedule options

frequency Requires Behaviour
hourly Runs every 60 minutes
daily time: "HH:MM" Runs once per day at the specified time
weekly time: "HH:MM", day: "<weekday>" Runs once per week on the specified day and time

Notification channels

Enable any combination of channels in config.yaml. Notifications are only sent when at least one Act has a material change.

  • Email — plain-text email via SMTP (supports TLS)
  • Slack — POST to a Slack incoming webhook URL
  • Webhook — POST raw JSON to any HTTP endpoint

The UK Employment Law Change Detector API

uk-reg-monitor delegates all intelligence to the UK Employment Law Change Detector API. That API analyses legislation pages and determines whether a material legislative change has occurred. uk-reg-monitor provides the scheduling, configuration, and notification layer on top.

The package connects to the live hosted API at https://uk-employment-law-change-detector.onrender.com by default — no additional setup is required. Interactive API documentation is available at https://uk-employment-law-change-detector.onrender.com/docs.

If you need to point at a different instance, set api.base_url in your config.yaml.


Development

# Run tests
pytest

# Run tests with coverage
pytest --cov=uk_reg_monitor

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uk_reg_monitor-0.2.5.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uk_reg_monitor-0.2.5-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file uk_reg_monitor-0.2.5.tar.gz.

File metadata

  • Download URL: uk_reg_monitor-0.2.5.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for uk_reg_monitor-0.2.5.tar.gz
Algorithm Hash digest
SHA256 9332c41c03716e9058bd76863cb8cddd617f29588a4d9e8598da7bff3cc39ddb
MD5 3a81e32f4dc02bbd6f63da7a529319c3
BLAKE2b-256 59345d0f9208053455c40dff943254b6be28f445364b8a112fa01b5e421586e5

See more details on using hashes here.

File details

Details for the file uk_reg_monitor-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: uk_reg_monitor-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for uk_reg_monitor-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b5382040cc9e0d7259601ad7aa81105861e8a056e62e8461a49e1caa73b8dca1
MD5 57eebcbfadcbc37a15afaabb084c55a0
BLAKE2b-256 e308dda517cd4700ef1883eb9a5cc48add1ea5687c92b179b1595f0dcf31a00a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page