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

    [email protected]:~# 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
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

Secretum Inc. 16 Oct 15, 2022
Personal and work vim 8 configuration with submodules

vimfiles Windows Vim 8 configuration files based on the recommendations of Ruslan Osipov, Keep Your vimrc file clean and The musings of bluz71. :help

1 Aug 27, 2022
Magnificent app which corrects your previous console command.

The Fuck The Fuck is a magnificent app, inspired by a @liamosaur tweet, that corrects errors in previous console commands. Is The Fuck too slow? Try t

Vladimir Iakovlev 75k Jan 02, 2023
Command-line search tool for GitHub

cligh is a command-line search tool for GitHub.

1 Oct 02, 2022
A very simple OpenContest command line client written in Python

OpenContest Client A very simple OpenContest command line client written in Python. The only dependency is the requests library. Tested with Linux onl

Ladue Computer Science 1 May 25, 2022
A CLI for creating styled-components for React projects quickly

new-component Ian Cleary (iancleary) Description Welcome! This is a CLI for creating styled-components for React projects quickly. Note: I've rewrote

Ian Cleary (he/him/his) 1 Feb 15, 2022
Fun project to generate The Matrix Code effect on you terminal.

Fun project to generate The Matrix Code effect on you terminal.

Henrique Bastos 11 Jul 13, 2022
CLI para o projeto Compilado (Newsletter e Podcast do Código Fonte TV)

Compilado CLI Automatização de tarefas através de linha de comando para a geração de assets para episódios do Compilado, a newsletter e podcast do can

Gabriel Froes 18 Nov 21, 2022
DShell, a tool that combines with discord.py and Jishaku to present to you, shell channels.

Discord shell or dshell for short is a Python package that combines with discord.py and Jishaku to transform an ordinary Discord channel into one capable of running bash commands using a Discord bot.

11 Nov 15, 2022
jenkins-tui is a terminal based user interface for Jenkins.

jenkins-tui 📦 jenkins-tui is a terminal based user interface for Jenkins. 🚧 ⚠️ This app is a prototype and in very early stages of development. Ther

Craig Gumbley 22 Oct 24, 2022
The project help you to quickly build layouts in terminal,cross-platform

The project help you to quickly build layouts in terminal,cross-platform

gojuukaze 133 Nov 30, 2022
googler is a power tool to Google (web, news, videos and site search) from the command-line.

googler is a power tool to Google (web, news, videos and site search) from the command-line.

Terminator X 5.9k Jan 04, 2023
A simple Python library that allows you to customize your CLI based output on Linux

Terminal-Colored-Print About A small module that allows to simply decorate strings on Linux terminals. I personally use it for multi-threaded project,

Francesco Milano 0 Dec 13, 2021
Terminal epub reader with inline images

nuber Inspired by epy, nuber is an Epub terminal reader with inline images written with Rust and Python using Überzug. Features Display images in term

Moshe Sherman 73 Oct 12, 2022
Yet another bash/zsh prompt script

Here we have yet another script for Git-aware customization of the command prompt in Bash and zsh. Unlike all the other scripts, I wrote this one, so

John T. Wodder II 5 Oct 13, 2021
Python CLI utility and library for manipulating SQLite databases

sqlite-utils Python CLI utility and library for manipulating SQLite databases. Some feature highlights Pipe JSON (or CSV or TSV) directly into a new S

Simon Willison 1.1k Jan 04, 2023
A simple python application for running a CI pipeline locally

A simple python application for running a CI pipeline locally This app currently supports GitLab CI scripts

Tom Stowe 0 Jan 11, 2022
Spotify Offline is a command line tool that allows one to download Spotify playlists in MP3 format.

Spotify Offline v0.0.2 listen to your favorite spotify songs, offline Overview Spotify Offline (spotifyoffline) is a command line tool that allows one

Aarush Gupta 1 Nov 28, 2021
Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages.

OpenCV on Wheels Pre-built CPU-only OpenCV packages for Python. Check the manual build section if you wish to compile the bindings from source to enab

OpenCV 3.2k Jan 04, 2023
Unofficial Open Corporates CLI: OpenCorporates is a website that shares data on corporations under the copyleft Open Database License. This is an unofficial open corporates python command line tool.

Unofficial Open Corporates CLI OpenCorporates is a website that shares data on corporations under the copyleft Open Database License. This is an unoff

Richard Mwewa 30 Sep 08, 2022