mirror of
https://github.com/unpoller/unpoller.git
synced 2026-03-31 06:33:57 -04:00
Restores the browser-based endpoint discovery script that was mistakenly removed in the Go --discover PR. Optional: use this for broader discovery (XHR capture) or unpoller --discover for known endpoints. Co-authored-by: Cursor <cursoragent@cursor.com>
1.5 KiB
1.5 KiB
UniFi endpoint discovery (headless)
Runs a headless browser against your UniFi controller, logs in, and records all API requests the UI makes. Use this to see which endpoints your controller exposes (e.g. when debugging 404s like device-tags #935).
What it does
- Launches Chromium (headless by default).
- Navigates to your UniFi controller URL.
- If it sees a login form, fills username/password and submits.
- Visits common UI paths to trigger API calls.
- Captures every XHR/fetch request to
/apior/proxy/(same origin). - Writes a markdown file:
API_ENDPOINTS_HEADLESS_YYYY-MM-DD.mdin this directory.
Quick start
cd tools/endpoint-discovery
python3 -m venv .venv
.venv/bin/pip install playwright
.venv/bin/playwright install chromium
UNIFI_URL=https://YOUR_CONTROLLER UNIFI_USER=admin UNIFI_PASS=yourpassword .venv/bin/python discover.py
The script writes API_ENDPOINTS_HEADLESS_<date>.md in the same directory. Paste that file (or its contents) in an issue or comment when reporting which endpoints your controller supports.
Options
- Headed (see the browser):
HEADLESS=falsebefore the command. - Output elsewhere:
OUTPUT_DIR=/path/to/dirbefore the command. - Use .env: Copy
.env.exampleto.env, set your values, then runpython discover.py(installpython-dotenvfor .env support).
Requirements
- Python 3.8+
- Direct controller URL (e.g.
https://192.168.1.1) works best; same-origin requests are captured.