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
A very simple and lightweight ToDo app using python that can be used from the command line

A very simple and lightweight ToDo app using python that can be used from the command line

Nilesh Sengupta 2 Jul 20, 2022
Python codecs extension featuring CLI tools for encoding/decoding anything

CodExt Encode/decode anything. This library extends the native codecs library (namely for adding new custom encodings and character mappings) and prov

Alex 210 Dec 30, 2022
🌈 Generate color palettes based on Neovim colorschemes.

Iris Iris is a Neovim plugin that generates a normalized color palette based on your colorscheme. It is named for the goddess Iris of Greek mythology,

N. G. Scheurich 45 Jul 28, 2022
ForX - get forex quotes from the terminal

A command line tool for checking exchange rates between currencies, both crypto and fiat.

Gabe Banks 52 Dec 10, 2022
MasterDuel Image Recognition Translation Command Line Tool

MasterDuelTranslate(Use Ygo Card DataBase,belong win32 window shot & image match)

PatchouliTC 77 Dec 01, 2022
This is a simple Termo application in command line style

my-termo This is a simple Termo application in command line style. This app run a Linux crontab task every day to get a new word. Type termo in your t

Gustavo Soares 1 Feb 14, 2022
git-partial-submodule is a command-line script for setting up and working with submodules while enabling them to use git's partial clone and sparse checkout features.

Partial Submodules for Git git-partial-submodule is a command-line script for setting up and working with submodules while enabling them to use git's

Nathan Reed 15 Sep 22, 2022
Open a file in your locally running Visual Studio Code instance from arbitrary terminal connections.

code-connect Open a file in your locally running Visual Studio Code instance from arbitrary terminal connections. Motivation VS Code supports opening

Christian Volkmann 56 Nov 19, 2022
Terminal Colored Text for Python

Terminal Colored Text for Python

R3CKhi-**75 3 Sep 10, 2022
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
Wordle helper: help you print posible 5-character words based on you input

Wordle Helper This program help you print posible 5-character words based on you

Gwan Thanakrit Juthamongkhon 4 Jan 19, 2022
A dec-bin converter uses 2's complement.

2's Complement Dec-Bin Converter A dec-bin converter uses 2's complement. Visit my Medium Post. What is 2's complement? Two's complement is the most c

Khaw Chi Hun (Jacky) 9 Mar 01, 2022
Ssl-tool - A simple interactive CLI wrapper around openssl to make creation and installation of self-signed certs easy

What's this? A simple interactive CLI wrapper around openssl to make self-signin

Aniket Teredesai 9 May 17, 2022
A simple CLI tool for getting region-specific status of Logz.io components.

About A simple CLI tool for checking the current status of Logz.io components per region. Built With Python 3 The following packeges (see requirements

Yotam Bernaz 1 Dec 11, 2021
Generate an ASCII Art from keyword put in the cli

ascii-art-generator-cli Generate an ASCII Art from keyword put in the cli Install git clone https://github.com/Nathanlauga/ascii-art-generator-cli cd

Nathan Lauga 1 Nov 14, 2021
CLTools provides various tools and command to use in the terminal.

CLTools provides various tools and command to use in the terminal. As of date, CLTools is only able to generate temporary email addresses and receive emails. There are plans to integrate more tools a

Ashwin Chugh 2 Feb 14, 2022
Kattis shell for getting examples, testing and submitting.

Kattis shell for getting examples, testing and submitting.

Simon Green Kristensen 15 Sep 30, 2022
Customisable pharmacokinetic model accessible via bash CLI allowing for variable dose calculations as well as intravenous and subcutaneous administration calculations

Pharmacokinetic Modelling Group Project A PharmacoKinetic (PK) modelling function for analysis of injected solute dynamics over time, developed by Gro

1 Oct 24, 2021
A simple CLI application helps you to find giant files that are eating up your system storage

Large file finder Sometimes it's very hard to find if some giant files are eating up your system storage. We might need to hunt those down. This simpl

Rahul Baruri 5 Nov 18, 2022
Zero-config CLI for TypeScript package development

Despite all the recent hype, setting up a new TypeScript (x React) library can be tough. Between Rollup, Jest, tsconfig, Yarn resolutions, ESLint, and

Jared Palmer 10.5k Jan 08, 2023