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
Play WORDLE game in your terminal.

Wordle TUI Play WORDLE game in your terminal. The game will be kept the same as the Web version. Prerequisites Python 3.7+ Linux/MacOS (Windows is not

Frost Ming 61 Oct 30, 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 VIM-inspired filemanager for the console

ranger 1.9.3 ranger is a console file manager with VI key bindings. It provides a minimalistic and nice curses interface with a view on the directory

12.6k Dec 30, 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
Convert shellcode into :sparkles: different :sparkles: formats!

Bluffy Convert shellcode into ✨ different ✨ formats! Bluffy is a utility which was used in experiments to bypass Anti-Virus products (statically) by f

pre.empt.dev 305 Dec 17, 2022
stonky is a simple command line dashboard for monitoring stocks.

stonky is a simple command line dashboard for monitoring stocks.

Jessy Williams 228 Dec 14, 2022
Konsave lets use save your KDE Plasma customizatios and restore them very easily!

Konsave (Save Plasma Customization) A CLI program that will let you save and apply your KDE Plasma customizations with just one command! Als

439 Jan 02, 2023
organize your books on the command line

organize your books on the command line

Ben Winston 19 Jan 21, 2022
open a remote repo locally quickly

A command line tool to peek a remote repo hosted on github or gitlab locally and view it in your favorite editor. The tool handles cleanup of the repo once you exit your editor.

Rahul Nair 44 Dec 16, 2022
A set of libraries and functions for simplifying automating Cisco devices through SecureCRT.

This is a set of libraries for automating Cisco devices (and to a lesser extent, bash prompts) over ssh/telnet in SecureCRT.

Matthew Spangler 7 Mar 30, 2022
Simple command line tool for text to image generation using OpenAI's CLIP and Siren (Implicit neural representation network)

Simple command line tool for text to image generation using OpenAI's CLIP and Siren (Implicit neural representation network)

Phil Wang 4.4k Jan 09, 2023
A **CLI** folder organizer written in Python.

Fsorter Introduction A CLI folder organizer written in Python. Dependencies Before installing, install the following dependencies: Ubuntu/Debain Based

1 Nov 17, 2021
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
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
A simple terminal-based localhost chat application written in python

Chat House A simple terminal-based localhost chat application written in python How to Use? Clone the repo git clone https://github.com/heksadecimal/c

Heks 10 Nov 09, 2021
A curated list of awesome things related to Textual

Awesome Textual | A curated list of awesome things related to Textual. Textual is a TUI (Text User Interface) framework for Python inspired by modern

Marcelo Trylesinski 5 May 08, 2022
CLI based diff viewer

Rich Diff CLI based diff viewer

Suresh Kumar 24 Nov 15, 2022
A collection of command-line interface games written in python

Command Line Interface Python Games Collection of some starter python game projects for beginners How to play these games Clone this repository git cl

Paras Gupta 7 Jun 06, 2022
A command line tool that creates a super timeline from SentinelOne's Deep Visibility data

S1SuperTimeline A command line tool that creates a super timeline from SentinelOne's Deep Visibility data What does it do? The script accepts a S1QL q

Juan Ortega 2 Feb 08, 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