Internet Speed Test using Python

Internet Speed Test using Python

Hello there, I am attending a Technical Writing Bootcamp at @hashnode. Hashnode Bootcamp III is a free virtual Bootcamp to help beginner technical writers to improve their writing skill. This article is inspired by the latest session by Sam Julien, @samjulien

TASK: Write 1 TIL format blog post on Hashnode to test out your own content system from drafting all the way to promoting.

Running a speed test can be very useful to verify the current state of an internet connection. In this Blog article, we will learn how to Test Internet Speed. We will see the implementation in Python.

Check out the Repository for Ultimate Resource in python. Drop a star if you find it useful! Got anything to add? Open a PR on the same!

Let's get started.

What will be covered in this Blog

1. speedtest Introduction
2. How to Test internet speed

Speedtest Introduction:

The internet connections in our homes and offices can differ by internet service providers (ISPs), allowable traffic limit, and most importantly speed. So what do you usually do when you want to test the speed our connection? You google it, right? How about testing the internet speed using Python from your machine!

Speedtest cli library provides Command line interface for testing internet bandwidth using

If you wish to know more about it, you can refer to Speedtest Documentation. Use this link to navigate to the documentation.

Now that you are aware of Speedtest basics, we can move forward to the coding section. Let's get started!

Time to Code!


You can find all the code at my GitHub Repository. Drop a star if you find it useful.

In order to access the Python library, you need to install it into your Python environment, use the following command to install Speedtest

pip install speedtest-cli

Now, let's import the package in our Python script.

import speedtest

Let's create an instance of Speedtest and call it st

st = speedtest.Speedtest()

Let's move forward and check for download speed. We will make use of download method to fetch the speed and store in d_st

d_st =

Similarly, to check for the upload speed, we will make use of upload method to fetch the speed and store in u_st

u_st = st.upload()

Once done, let's display the download and upload speed.

print("Your Download speed is", d_st) 
print("Your Upload speed is", u_st)

Let's have a look at the output:

Your Download speed is 4786516.020362539
Your Upload speed is 851493.59380959

It will look something like this. Here's the download and upload speed in bits.


Let's check for ping. We can do so by making use of the following command.


Let's fetch the ping and store it in ping, we will make use of for the same.

ping =

#display the result
print("Your Ping is", ping)

Let's display the ping using print.

Your Ping is 50.846

This is how you can test your Internet speed. That's it!

Simple, isn't it? Hope this tutorial has helped.You can play around with the Speedtest library and even explore more features. You can even make use of Python GUI using Tkinter.

You can find all the code at my GitHub Repository. Drop a star if you find it useful.

Thank you for reading, I would love to connect with you at Twitter | LinkedIn.

Do share your valuable suggestions, I appreciate your honest feedback!

You should definitely check out my other Blogs:


See you in my next Blog article, Take care

Did you find this article valuable?

Support Ayushi Rawat by becoming a sponsor. Any amount is appreciated!