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
Standalone script written in Python 3 for generating Reverse Shell one liner snippets and handles the communication between target and client using custom Netcat binaries

Standalone script written in Python 3 for generating Reverse Shell one liner snippets and handles the communication between target and client using custom Netcat binaries. It automates the boring stu

Yash Bhardwaj 3 Sep 27, 2022
A simple script that outputs the current date on the user interface/terminal.

Py-Date A simple script that outputs the current date on the user interface/terminal. How to Run Open your terminal and cd into the folder containi

Arinzechukwu Okoye 1 Jan 13, 2022
A CLI Spigot plugin manager that adheres to Unix conventions and Python best practices.

Spud A cross-platform, Spigot plugin manager that adheres to the Unix philosophy and Python best practices. Some focuses of the project are: Easy and

Tommy Dougiamas 9 Dec 02, 2022
Find your broken links, so users don't.

PyAnchor Dead links are an annoyance for websites with an extensive amount of content. A side from the negative impact on SEO, dead links are an annoy

Ricky White 61 Dec 14, 2022
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
Wordle for CLUE - WORDLE clone for Adafruit Clue

Wordle_for_CLUE This project is a clone of the very popular word solving puzzle

Michael Lacock 4 Feb 15, 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

14 Sep 11, 2022
A webmining CLI tool & library for python.

minet is a webmining command line tool & library for python (= 3.6) that can be used to collect and extract data from a large variety of web sources

médialab Sciences Po 165 Dec 17, 2022
Simple CLI prompt for easy I/O with OpenAI's API

openai-cli-prompt Simple CLI prompt for easy I/O with OpenAI's API Quickstart Create a .env file with: OPENAI_API_KEY=Your OpenAI API Key Configure

Erik Nomitch 1 Oct 12, 2021
alternative cli util for update-alternatives

altb altb is a cli utility influenced by update-alternatives of ubuntu. Linked paths are added to $HOME/.local/bin according to XDG Base Directory Spe

Elran Shefer 8 Dec 07, 2022
StackOverflow in your terminal.

how. How do I ...? This project was started to help developers ask more questions. Table of Contents Installation Usage Foss Community Copyright Insta

Ron Nathaniel 2 Jan 31, 2022
pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery.

pypinfo: View PyPI download statistics with ease. pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery. Installation pypin

Ofek Lev 351 Dec 26, 2022
CLI client for RFC 4226's HOTP and RFC 6238's TOTP.

One Time Password (OTP, TOTP/HOTP) OTP serves as additional protection in case of password leaks. onetimepass allows you to manage OTP codes and gener

Apptension 4 Jan 05, 2022
An interactive aquarium for your terminal.

sipedon An interactive aquarium for your terminal, written using pytermgui. The project got its name from the Common Watersnake, also known as Nerodia

17 Nov 07, 2022
Simple Digital Ocean CLI by python.

Simple Digital Ocean CLI by python.

Chiro 2 Jan 01, 2023
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 04, 2022
This is the public repo for the VS Code Extension AT&T i386/IA32 UIUC-ECE391 Syntax Highlighting

AT&T i386 IA32 UIUC ECE391 GCC Highlighter & Snippet & Linter This is the VS Code Extension for UIUC ECE 391, MIT 6.828, and all other AT&T-based i386

Jackgetup 1 Feb 05, 2022
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
This a simple tool to query the awesome ippsec.rocks website from your terminal

ippsec-cli This a simple tool to query the awesome ippsec.rocks website from your terminal Installation and usage cd /opt git clone https://github.com

stark0de 5 Nov 26, 2022
Trans is a dependency-free CLI for Google Translate

Trans is a dependency-free CLI for Google Translate

11 Jan 04, 2022