Command line interface for testing internet bandwidth using speedtest.net

Overview

speedtest-cli

Command line interface for testing internet bandwidth using speedtest.net

Latest Version Travis License

Versions

speedtest-cli works with Python 2.4-3.7

Versions

Installation

pip / easy_install

pip install speedtest-cli

or

easy_install speedtest-cli

Github

pip install git+https://github.com/sivel/speedtest-cli.git

or

git clone https://github.com/sivel/speedtest-cli.git
cd speedtest-cli
python setup.py install

Just download (Like the way it used to be)

wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli

or

curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli

Usage

$ speedtest-cli -h
usage: speedtest-cli [-h] [--no-download] [--no-upload] [--single] [--bytes]
                     [--share] [--simple] [--csv]
                     [--csv-delimiter CSV_DELIMITER] [--csv-header] [--json]
                     [--list] [--server SERVER] [--exclude EXCLUDE]
                     [--mini MINI] [--source SOURCE] [--timeout TIMEOUT]
                     [--secure] [--no-pre-allocate] [--version]

Command line interface for testing internet bandwidth using speedtest.net.
--------------------------------------------------------------------------
https://github.com/sivel/speedtest-cli

optional arguments:
  -h, --help            show this help message and exit
  --no-download         Do not perform download test
  --no-upload           Do not perform upload test
  --single              Only use a single connection instead of multiple. This
                        simulates a typical file transfer.
  --bytes               Display values in bytes instead of bits. Does not
                        affect the image generated by --share, nor output from
                        --json or --csv
  --share               Generate and provide a URL to the speedtest.net share
                        results image, not displayed with --csv
  --simple              Suppress verbose output, only show basic information
  --csv                 Suppress verbose output, only show basic information
                        in CSV format. Speeds listed in bit/s and not affected
                        by --bytes
  --csv-delimiter CSV_DELIMITER
                        Single character delimiter to use in CSV output.
                        Default ","
  --csv-header          Print CSV headers
  --json                Suppress verbose output, only show basic information
                        in JSON format. Speeds listed in bit/s and not
                        affected by --bytes
  --list                Display a list of speedtest.net servers sorted by
                        distance
  --server SERVER       Specify a server ID to test against. Can be supplied
                        multiple times
  --exclude EXCLUDE     Exclude a server from selection. Can be supplied
                        multiple times
  --mini MINI           URL of the Speedtest Mini server
  --source SOURCE       Source IP address to bind to
  --timeout TIMEOUT     HTTP timeout in seconds. Default 10
  --secure              Use HTTPS instead of HTTP when communicating with
                        speedtest.net operated servers
  --no-pre-allocate     Do not pre allocate upload data. Pre allocation is
                        enabled by default to improve upload performance. To
                        support systems with insufficient memory, use this
                        option to avoid a MemoryError
  --version             Show the version number and exit

Python API

See the wiki.

Inconsistency

It is not a goal of this application to be a reliable latency reporting tool.

Latency reported by this tool should not be relied on as a value indicative of ICMP style latency. It is a relative value used for determining the lowest latency server for performing the actual speed test against.

There is the potential for this tool to report results inconsistent with Speedtest.net. There are several concepts to be aware of that factor into the potential inconsistency:

  1. Speedtest.net has migrated to using pure socket tests instead of HTTP based tests
  2. This application is written in Python
  3. Different versions of Python will execute certain parts of the code faster than others
  4. CPU and Memory capacity and speed will play a large part in inconsistency between Speedtest.net and even other machines on the same network

Issues relating to inconsistencies will be closed as wontfix and without additional reason or context.

Comments
  • Added CSV mode

    Added CSV mode

    I'm happy to make this sugestion as my first GitHub contribution to a project :-). I've added a --csv filename mode that write speedtest results to that filename.

    speedtest-cli --csv bandwith_report.csv
    

    If the file doesn't extists it generates a new one with a header. If it cannot write launches an error. This is a sample result:

    Test server;Date/Time;Latency;Dowload Speed (Kb/s);Upload Speed (Kb/s)
    Grupo TVHoradada (Pilar De La Horadada) [87.32 km];2015-07-06T11:28:32.013159;64.8;59847;25499
    Grupo TVHoradada (Pilar De La Horadada) [87.32 km];2015-07-06T11:29:30.652184;62.22;59636;25775
    TVAlmansa S.L. (Almansa) [50.87 km];2015-07-06T11:32:33.344205;85.19;60257;24798
    TVAlmansa S.L. (Almansa) [50.87 km];2015-07-06T11:33:29.556000;62.26;58992;25111
    ...
    

    You can install a cron jon to execute the test each hour for example and store results for future analysis or graphic.

    $crontab -e
    0 */1 * * * /home/myuser/speedtest-cli --csv bandwith_report.csv >> /dev/null
    

    Edited: Standar output is been redirected to /dev/null in crontab. It could be interesting to add a --silent mode to use in combination with --csv

    enhancement maybe on-hold needs-revision 
    opened by gonzalo 10
  • Bug fixes, etc.

    Bug fixes, etc.

    If multiple servers reported the exact same lat. and long. then they would overwrite eachother in the dict. I changed it to use a dict of lists so that you could have multiple servers with the exact same distance. (3 of my closest 5 reported the exact same corrdinates.)

    The latency it was printing was not the latency from the chosen best server. Now it is.

    Added a print out of the IP and ISP info.

    opened by xombiemp 7
  • Test against static servers

    Test against static servers

    I've added a option to test against a list of servers loaded from a json file.

    I needed this option because the server I wanted to test against sometimes didn't appeared in speedtest.get_servers()

    Now we can define one ore more servers like this: example-server.json

    {
        "313.8447559412203": [
            {
                "url": "http://speedtest.glasfaser-ostbayern.de:8080/speedtest/upload.php",
                "lat": "49.0167",
                "lon": "12.0833",
                "name": "Regensburg",
                "country": "Germany",
                "cc": "DE",
                "sponsor": "R-KOM GmbH & Co. KG",
                "id": "4404",
                "host": "speedtest.glasfaser-ostbayern.de:8080",
                "d": 313.8447559412203
            }
        ]
    }
    
    opened by mietzen 6
  • update: add --search

    update: add --search

    #726 #717

    
    python speedtest.py --search="United States"
    # python speedtest.py --search "United States"
    # set server by search result
    python speedtest.py --search="United States" --server 18531
    # test command
    curl -s https://raw.githubusercontent.com/du5/speedtest-cli/7b3309c/speedtest.py \
    | python - --search="United States"
    
    pip install git+https://github.com/du5/speedtest-cli.git
    speedtest --search="Hong Kong"
    speedtest --search="Hong Kong" --server=13538 --share
    
    opened by du5 6
  • Safeguard against sum() errors + catch bad status codes

    Safeguard against sum() errors + catch bad status codes

    Safeguard against sum() errors in case on "None" values. Those None values can appear if the requests somehow failed, see https://github.com/sivel/speedtest-cli/issues/752

    Also gracefully catch and handle invalid status code responses.

    opened by spacegaier 5
  • Added support for binding connections to a specific network interface.

    Added support for binding connections to a specific network interface.

    I added support for binding sockets to a specific network interface since specifying the source ip is not enough on Linux based platforms.

    The implementation was done by setting the SO_BINDTODEVICE socket option, according to this Stack Overflow Answer..

    The interface will be passed as an argument like following --interface INTERFACE, for example --interface wlan0.

    This feature will also solve issue #668.

    opened by cicioflaviu 5
  • [OUTPUT STYLE] Download and Upload

    [OUTPUT STYLE] Download and Upload

    Hi @sivel 👋,

    I changed the style of output.

    Before: 5ncRPSBXk

    After: 5ncRyQ3W4

    The old output looked weird and it was very complicated. To me, this new output looks cute and simple. That's why I decided to renew it, I hope you like it.

    Best regards, Mert DoÄŸu.

    opened by ReXulEc 4
  • Issue on --list

    Issue on --list

    Issue on the list command

    root@prometheus:~# speedtest-cli --list
    Retrieving speedtest.net configuration...
    Traceback (most recent call last):
      File "/usr/bin/speedtest-cli", line 2000, in <module>
        main()
      File "/usr/bin/speedtest-cli", line 1986, in main
        shell()
      File "/usr/bin/speedtest-cli", line 1875, in shell
        secure=args.secure
      File "/usr/bin/speedtest-cli", line 1091, in __init__
        self.get_config()
      File "/usr/bin/speedtest-cli", line 1174, in get_config
        map(int, server_config['ignoreids'].split(','))
    ValueError: invalid literal for int() with base 10: '
    
    opened by killmasta93 4
  • Working plotly integration

    Working plotly integration

    May be of interest, may not.

    I wanted something that would allow me to easily monitor link quality over time; this is pretty easy for latency etc but nothing gave me an automated way of graphing speedtests.

    The changes simply add a --plotly option which, if used, will spit out the upload, download and latency measurements from the results dict to the online graphing service, subsequent runs will append to the existing graph, with the timestamps for the X axis also being taken from the results dict.

    Example graph output (mine) is here: https://plot.ly/~matjohn2/6.embed

    Have also added a little Dockerfile and info in the readme as to how I use this, but like I said, may be of little interest to the wider speedtest-cli community, could have created a separate wrapper using the API, but only just noticed the API when submitting the PR ;)

    opened by metahertz 4
  • Use HTTPS for speedtest.net URLs

    Use HTTPS for speedtest.net URLs

    opened by mathiasbynens 4
  • New options

    New options

    My requirement was to perform periodic automated tests to different servers while building up a file of results. This allows a "health check" to be performed on internet connection to see if particular times of day had better internet speeds. New options added: (1) Allow saving and loading configuration. Allows local configuration file to be used for automated tests. (2) Allow saving and loading of server list. Allows a custom server list to be supplied for automated speed tests allowing different distance servers to be used. (3) Allow saving of test results. Allows automated speed testing to build up a file of test results for long term testing. File format is csv.

    opened by hominator 4
  • Support binding to a client port in addition to a client address.

    Support binding to a client port in addition to a client address.

    I'd like speedtest to be able to bind to a client port, in addition to an IP. I extended source_address to support IP:PORT scheme and made it so you could optionally include the port or the IP address. The reason I want to bind to a client port is that I want my firewall to be route the speedtest through different external gateways based on the client port. This allows me to run speed tests against the different egress routes on my network but run the speedtest from a device that is not my router. This should be entirely backwards compatible.

    opened by scottmsilver 0
  • Added a method for converting a server dictionary to a server list

    Added a method for converting a server dictionary to a server list

    I found the following error in the code if I want to get a better server this way:

    sp = speedtest.Speedtest()
    best_servers = sp.get_servers()
    sp.get_best_server(best_servers)
    

    I get an error:

    Traceback (most recent call last):
      File "/speedtest/main.py", line 18, in <module>
        test_connection()
      File "/speedtest/main.py", line 8, in test_connection
        sp.get_best_server(best_servers)
      File "\speedtest\venv\lib\site-packages\speedtest.py", line 1459, in get_best_server
        url = os.path.dirname(server['url'])
    TypeError: 'float' object is not subscriptable
    

    I also added the else block, otherwise the condition is incorrect on line 1456.

    opened by Tivasic 0
  • Add option --custom to perform test with custom servers

    Add option --custom to perform test with custom servers

    Hello. I added the --custom argument so that users can include a URL like https://www.speedtest.net/api/js/servers?engine=js&search=orange&https_functional=true&limit=1 and perform speedtests against a server of their liking.

    Update 7/3/2022:

    • added interoperability feature to make --custom work alongside with --server that way we can choose a specific server from custom link.

    For instance, a command like speedtest --custom "https://www.speedtest.net/api/js/servers?engine=js&search=Comcast&https_functional=true" --server 37808 should ping Comcast (Atlanta, GA)

    opened by edseldim 0
Releases(v2.1.3)
Owner
Matt Martz
Ansible Core Engineering Architect and Technical Team Lead
Matt Martz
Command line tool for interacting and testing warehouse components

Warehouse debug CLI Example usage for Zumo debugging See all messages queued and handled. Enable by compiling the zumo-controller with -DDEBUG_MODE_EN

null 1 Jan 3, 2022
A supercharged AWS command line interface (CLI).

SAWS Motivation AWS CLI Although the AWS CLI is a great resource to manage your AWS-powered services, it's tough to remember usage of: 70+ top-level c

Donne Martin 5.1k Jan 5, 2023
Universal Command Line Interface for Amazon Web Services

This package provides a unified command line interface to Amazon Web Services.

Amazon Web Services 13.3k Jan 7, 2023
command line interface to manage VALORANT skins

A PROPER RELEASE IS COMING SOON, IF YOU KNOW HOW TO USE PYTHON YOU CAN USE IT NOW! valorant skin manager command line interface simple command line in

colinh 131 Dec 25, 2022
Microsoft Azure CLI - Azure Command-Line Interface

A great cloud needs great tools; we're excited to introduce Azure CLI, our next generation multi-platform command line experience for Azure.

Microsoft Azure 3.4k Dec 30, 2022
flora-dev-cli (fd-cli) is command line interface software to interact with flora blockchain.

Install git clone https://github.com/Flora-Network/fd-cli.git cd fd-cli python3 -m venv venv source venv/bin/activate pip install -e . --extra-index-u

null 14 Sep 11, 2022
A command line interface to buy things in stregsystemet

Stregsystemet-CLI This repository is the Stregsystemet CLI, to buy things in Stregsystemet, at AAU. Use of this cli-tool is at your own risk and there

F-klubben 14 Oct 18, 2022
moviepy-cli: Command line interface for MoviePy.

Moviepy-cli is designed to apply several video editing in a single command with Moviepy as an alternative to Video-cli.

Kentaro Wada 23 Jun 29, 2022
Command line interface for unasync

CLI for unasync Command line interface for unasync Getting started Install Run the following command to install the package with pip: pip install unas

Leynier Gutiérrez González 3 Apr 4, 2022
Rover is a command line interface application that allows through browse through mission data, images, metadata from the NASA Official Website

?? rover Rover is a command line interface application that allows through browse through mission data, images, metadata from the NASA Official Websit

Saketha Ramanjam 4 Jan 19, 2022
bsp_tool provides a Command Line Interface for analysing .bsp files

bsp_tool Python library for analysing .bsp files bsp_tool provides a Command Line Interface for analysing .bsp files Current development is focused on

Jared Ketterer 64 Dec 28, 2022
Investing library and command-line interface inspired by the Bogleheads philosophy

Lakshmi (Screenshot of the lak command in action) Background This project is inspired by Bogleheads forum. Bogleheads focus on a simple but powerful p

Sarvjeet Singh 108 Dec 26, 2022
âš™ A lightweight command line interface library for creating commands.

âš™ A lightweight command line interface library for creating cli commands. About | Installation | Usage | Features | Contributors | License About Next:

Serum 16 Sep 25, 2022
Command-line interface to PyPI Stats API to get download stats for Python packages

pypistats Python 3.6+ interface to PyPI Stats API to get aggregate download statistics on Python packages on the Python Package Index without having t

Hugo van Kemenade 140 Jan 3, 2023
A minimal and ridiculously good looking command-line-interface toolkit.

Pyceo Pyceo is a Python package for creating beautiful, composable, and ridiculously good looking command-line-user-interfaces without having to write

Juan-Pablo Scaletti 21 Mar 25, 2022
Quo is a Python based toolkit for writing Command-Line Interface(CLI) applications.

Quo is a Python based toolkit for writing Command-Line Interface(CLI) applications. Quo is making headway towards composing speedy and orderly CLI applications while forestalling any disappointments brought about by the failure to execute a CLI API. Simple to code, easy to learn, and does not come with needless baggage.

Secretum Inc. 16 Oct 15, 2022
The command line interface for Gradient - Gradient is an an end-to-end MLOps platform

Gradient CLI Get started: Create Account • Install CLI • Tutorials • Docs Resources: Website • Blog • Support • Contact Sales Gradient is an an end-to

Paperspace 58 Dec 6, 2022
Program Command Line Interface (CLI) Sederhana: Pemesanan Nasi Goreng Hekel

Program ini merupakan aplikasi yang berjalan di dalam command line (terminal). Program ini menggunakan built-in library python yaitu argparse yang dapat menerima parameter saat program ini dijalankan melalui terminal atau CLI.

Habib Abdurrasyid 5 Nov 19, 2021
A command line interface to interact with the Hypixel api allowing the user to get stats, leaderboards, etc

HyConsole is a way to get data on players and leaderboards from the Hypixel Minecraft server from the command line. Keep in mind I have no a

null 1 Feb 14, 2022