mirror of
https://github.com/unpoller/unpoller.git
synced 2026-03-31 06:24:21 -04:00
- Python script (Playwright) that logs in to UniFi controller and captures XHR/fetch requests to /api and /proxy/ endpoints - Writes API_ENDPOINTS_HEADLESS_<date>.md in tool directory (easy for users) - Helps debug 404s (e.g. device-tags #935): users can run and share output - Optional, read-only; not required for building or running unpoller
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.