Skip to main content

speedtest-ng

CI PyPI version Python versions Downloads License: Apache-2.0

Modern, actively maintained Python 3.11+ asyncio and raw-TCP (OoklaServer) successor to sivel/speedtest-cli, providing both a CLI (speedtest / speedtest-cli) and a drop-in library API (import speedtest) engineered for Gigabit+ fiber accuracy and Home Assistant's speedtestdotnet integration.

Attribution: speedtest-ng is an independent continuation of Matt Martz's archived sivel/speedtest-cli project (Copyright 2012 Matt Martz), preserving the Apache License 2.0 and full Git history.

What's New in 3.0.0

  • Native AsyncSpeedtest + Injectable aiohttp.ClientSession: Run directly on an existing asyncio event loop without thread-pool blocking, while keeping the synchronous Speedtest facade 100% drop-in compatible.
  • Clean-Room OoklaServer Raw TCP (:8080) Transport + Automatic HTTP Fallback: Speaks HI/HELLO, PING/PONG, DOWNLOAD, UPLOAD, QUIT with 256 KiB shared memoryview buffers and transparent fallback to keep-alive aiohttp when port 8080 is unreachable.
  • Dynamic Multi-Stream Scaling & Statistical Windowing: Scales streams dynamically on Gigabit+ links, discards TCP slow-start warm-up and outliers via trimmed mean, and reports additive jitter, packet_loss, loaded_ping_download, loaded_ping_upload, and protocol fields.
  • Modern JSON Server Discovery: Queries Speedtest.net's /api/js/servers endpoint first (fixing stale/distant 10-server XML fallbacks) with automatic XML fallback and HTTPS (secure=True) by default.
  • Reliability & Leak Fixes: Eliminates phantom 1,800,000 ms latency values on unreachable servers, removes multi-MB per-request upload buffer allocations and stdout/stderr fd wrapping leaks, refreshes timestamps between reused runs, and removes Python 2.4–3.10 shims.

Installation

uv add speedtest-ng

or with pip:

pip install speedtest-ng

CLI Usage

speedtest --simple
speedtest --json
speedtest --protocol tcp
speedtest --protocol http --no-secure
speedtest --list
speedtest --server 19911 --bytes

Key CLI options:

  • --protocol {auto,tcp,http} — Transfer transport (auto prefers raw TCP :8080 with automatic HTTP fallback).
  • --simple, --json, --csv, --csv-delimiter, --csv-header — Output formats.
  • --bytes — Report human-readable output in MB/s instead of Mbit/s.
  • --no-download, --no-upload, --single — Run partial or single-stream tests.
  • --server ID, --exclude ID, --list, --mini URL — Server discovery and selection.
  • --secure (default) / --no-secure, --source IP, --timeout SEC, --share, --version.

Python API

import asyncio
import aiohttp
from speedtest import AsyncSpeedtest


async def main() -> None:
    async with aiohttp.ClientSession() as session:
        client = AsyncSpeedtest(session=session)
        await client.get_servers()
        best = await client.get_best_server()
        download_bps = await client.download()
        upload_bps = await client.upload()
        print(
            best["sponsor"], client.results.ping, download_bps / 1e6, upload_bps / 1e6
        )


asyncio.run(main())

Synchronous Drop-In API (speedtest-cli Compatible)

import speedtest

api = speedtest.Speedtest(secure=True)
api.get_servers()
best = api.get_best_server()
api.download()
api.upload()
results = api.results.dict()
print(results["ping"], results["download"] / 1e6, results["upload"] / 1e6)

Development

uv sync --all-groups
uv run ruff check --no-fix .
uv run ruff format --check .
uv run mypy speedtest tests
uv run pytest

Opt-in live Speedtest.net tests:

uv run pytest -m real_api_call --no-cov

Metadata

Release files for speedtest-ng 3.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for speedtest-ng 3.0.1
File Size Uploaded Provenance Actions
speedtest_ng-3.0.1.tar.gz 157.3 kB With provenance Details for speedtest_ng-3.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for speedtest-ng 3.0.1
File Interpreter ABI Platform Actions
speedtest_ng-3.0.1-py3-none-any.whl Python 3 none any Details for speedtest_ng-3.0.1-py3-none-any.whl

Total release size: 190.9 kB

Release files / speedtest_ng-3.0.1.tar.gz

Download URL speedtest_ng-3.0.1.tar.gz
Size 157.3 kB
Tags Source
SHA-256 checksum
How to use checksums
aa161d11b1f21a9ece9c6061122fa3207795ed62bfa7138a3eb56a9a14cf354f
BLAKE2b-256 checksum
How to use checksums
1fbd3356cf406430f8a844acbadf0a5f0593441af970e5852430cb4972bb935d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / speedtest_ng-3.0.1-py3-none-any.whl

Download URL speedtest_ng-3.0.1-py3-none-any.whl
Size 33.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0f03dd708da2dc680be6f44a7bc749605567a7d5380c0f8176522fff4ac2c1e
BLAKE2b-256 checksum
How to use checksums
eaeecdbf81ef69d275e136962bc2d34f0964e9fd52530bc4bdf6a51152d9c082
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for speedtest-ng 3.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for speedtest_ng-3.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page