https://github.com/notaussie/speedtest.py
A simple OOP wrapper for Ookla's Speedtest CLI.
https://github.com/notaussie/speedtest.py
cli-wrapper python python-3-10 python3 speedtest-cli wrapper
Last synced: 4 months ago
JSON representation
A simple OOP wrapper for Ookla's Speedtest CLI.
- Host: GitHub
- URL: https://github.com/notaussie/speedtest.py
- Owner: NotAussie
- License: mit
- Created: 2024-02-21T05:14:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-22T11:43:11.000Z (over 1 year ago)
- Last Synced: 2024-02-23T06:39:07.979Z (over 1 year ago)
- Topics: cli-wrapper, python, python-3-10, python3, speedtest-cli, wrapper
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## `🛜` Speedtest.py
> This project is not an offical Speedtest wrapper and therefore is not endorsed by Ookla.Speedtest.py is a simple asynchronous wrapper for [Speedtest.net](https://www.speedtest.net/) built around the OOP coding style. We also use zero external packages/modules.
## `📥` Installing
> Speedtest.py requires the [Speedtest.net CLI](https://www.speedtest.net/apps/cli) to function.
PIP: `pip install speedtest.py`
> We're in the works of publishing to PIP.
Conda: `conda install speedtest.py`
> We're currently not published on Conda## `✨` Example
Examples of using Speedtest.py### 1: Basic speedtest
```python
# Imports
from speedtest import Client
import asyncio# Define the client
client = Client(
executable="speedtest" # Only needs changing on Windows or Linux installs that have a different executable/command name.
)# Define app function
async def app():
# Run a test with an automatically picked server
result = await client.test()# Print statistics
print(f"Download bandwidth: {str(result.download.bandwidth) * 8 / 1_000_000:.2f} Mbps")
print(f"Upload bandwidth: {str(result.upload.bandwidth) * 8 / 1_000_000:.2f} Mbps")asyncio.run(app())
```### 2: Speedtest with selected server
```python
# Imports
from speedtest import Client
import asyncio# Define the client
client = Client(
executable="speedtest" # Only needs changing on Windows or Linux installs that have a different executable/command name.
)# Define app function
async def app():
# Get a list of nearby servers
servers = await client.servers()# Run a test with the first server
result = await client.test(server=servers[0])# Print statistics
print(f"Download bandwidth: {str(result.download.bandwidth) * 8 / 1_000_000:.2f} Mbps")
print(f"Upload bandwidth: {str(result.upload.bandwidth) * 8 / 1_000_000:.2f} Mbps")asyncio.run(app())
```