Find upload and download speed using python

In this python article, you are going to learn how to find the upload and download speed using python. This is made possible with the help of a python package called speedtest-cli.

upload speed vs download speed

Download speed is the speed that information on the Internet (e.g., text and graphics) is transferred to your computer; that is, how long it takes your computer to load websites and download files to display on your screen. 

Upload speed is the speed that your computer can transfer or send information to the Internet. For example, if you want to send photos to a website to be printed by your local vendor, you “upload” the photos to the site. Download speeds normally happen at faster speeds than uploads; however, that can depend on broadband connections or how web pages are created.

Installation

First we have to install the python package. Let us install the package from pypi.org by running the following command in your terminal.

$ pip install speedtest-cli

Once we have installed the package we are good to go.

Upload speed

The following code snippet shows you how to find the upload speed of your internet using python. First import the speedtest module. Then call the Speedtest class from the speedtest module. This class has a method called upload() which will return the upload speed of our internet.

upload speed using python

The output of the above code is,

1909473.8016499544

Download speed

The following code snippet shows you how to find the download speed of your internet using python. First import the speedtest module. Then call the Speedtest class from the speedtest module. This class has a method called download() which will return the upload speed of our internet.

download speed using python

The output of the above code snippet is,

28163578.966083042

Conclusion

Hope this article is helpful. Follow this blog regularly for more interesting articles.

Happy coding!