A comprehensive overview of top diagnostic services and their APIs
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.
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()
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.
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
}
Cloudflare offers deep insights into network quality, including jitter and packet loss. Essential for gamers and remote workers using VoIP/Zoom.
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();
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.
// 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`);
}
}
);
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.
// Requires SpeedOf.Me API script to be loaded
SomApi.account = "API_KEY_HERE";
SomApi.onTestCompleted = (res) => {
alert("Speed: " + res.download + " Mbps");
};
SomApi.startTest();