A colorful terminal wrapper around Ookla's official speedtest CLI with live progress bars and stable JSON output for scripts.
PythonCLINetworkingDevEx
Speedtest CLI is a small terminal wrapper that makes Ookla's official speedtest binary genuinely pleasant to run and easy to script against. Ookla's own CLI works, but it isn't built for a human watching a terminal or a script consuming the result — this fills that gap in about 300 lines of pure Python 3 with no dependencies.
What it does
Running it live-streams Ookla's JSONL progress events and renders them as colored progress bars for ping, download, and upload, then prints a formatted summary with server, ISP, and result-URL info. For scripts, three flatter output modes skip the animation entirely:
speedtest-cli --simple # one-line summary
speedtest-cli --json # compact, stable JSON schema
speedtest-cli --raw-json # Ookla's full raw result
Notable details
- It shells out to the real Ookla binary rather than reimplementing the speed-test protocol, so the numbers match what speedtest.net itself would report — a deliberate tradeoff of a bit of process-management complexity for measurement accuracy.
- It defends against a naming collision. The Python
speedtest-cliPyPI package installs its ownspeedtestcommand that produces different, less accurate numbers. A startup check runsspeedtest --versionand confirms the output actually says "Ookla" before trusting it, rather than assuming the first binary on PATH is the right one. - The JSON schema is versioned deliberately. An early version of
--jsonproduced a compact schema that other scripts came to depend on. Rather than break that when Ookla's full result format was wired in,--jsonkeeps translating into the original shape, and a new--raw-jsonflag exposes the complete data — jitter, packet loss, result URL — for anything that wants it. - Streaming avoids a deadlock. The subprocess reads Ookla's stdout line by line as newline-delimited JSON instead of buffering, and deliberately leaves stderr connected to the parent terminal — an earlier version that piped stderr could hang if Ookla filled that buffer.