Network Speed Test Guide 🌐

A comprehensive overview of top diagnostic services and their APIs

1. Ookla (Speedtest.net)

The Industry Leader

Ookla is the most accurate and widely used service globally. While they don't offer a free open REST API, their CLI tool is the best way for developers to automate testing via scripts.

Example: Python Script (speedtest-cli)

import speedtest

def run_test():
    servers = []
    threads = None
    s = speedtest.Speedtest()
    s.get_best_server()
    
    print(f"Testing... 📥")
    download = s.download() / 10**6 # Convert to Mbps
    upload = s.upload() / 10**6 # Convert to Mbps
    
    print(f"Download: {download:.2f} Mbps")
    print(f"Upload: {upload:.2f} Mbps")
    print(f"Ping: {s.results.ping} ms")

run_test()

2. Fast.com (by Netflix)

Minimalist & Video-Centric

Powered by Netflix, this test specifically checks connection speed to their content delivery network (CDN). It's simple, fast, and great for detecting ISP throttling.

Pro Tip: Use the fast-cli package in Node.js to get JSON output directly in your console.
// Command: npx fast-cli --json

// Output example:
{
  "downloadSpeed": 95,
  "uploadSpeed": 40,
  "downloadUnit": "Mbps",
  "bufferBloat": 18
}

3. Cloudflare Speed Test

Power User Metrics

Cloudflare offers deep insights into network quality, including jitter and packet loss. Essential for gamers and remote workers using VoIP/Zoom.

Example: Fetching Latency

async function checkNetwork() {
    const start = Date.now();
    // Fetching from Cloudflare's edge server
    await fetch('https://1.1.1.1/cdn-cgi/trace');
    const latency = Date.now() - start;
    console.log(`Latency to Edge: ${latency}ms`);
}

checkNetwork();

4. M-Lab (Measurement Lab)

Open Source & Research

A collaboration between Google and researchers. M-Lab provides the NDT (Network Diagnostic Tool). All data collected is public domain, making it the best for transparent network research.

Example: ndt7 Protocol (JavaScript)

// Modern NDT7 implementation uses WebSockets for real-time data
import ndt7 from '@m-lab/ndt7';

ndt7.test(
    { userAcceptedDataPolicy: true },
    {
        onDownloadMeasurement: (m) => {
            const speed = (m.AppInfo.NumBytes / m.AppInfo.ElapsedTime * 8);
            console.log(`Live Speed: ${speed.toFixed(2)} Mbps`);
        }
    }
);

5. SpeedOf.Me

HTML5 Native

One of the oldest HTML5-based tests. It doesn't require any plugins and works perfectly on mobile browsers. They offer a robust Commercial API for integration into third-party apps.

Example: API Usage

// Requires SpeedOf.Me API script to be loaded
SomApi.account = "API_KEY_HERE";

SomApi.onTestCompleted = (res) => {
    alert("Speed: " + res.download + " Mbps");
};

SomApi.startTest();