An open API service indexing awesome lists of open source software.

https://github.com/bernhardangerer/simple-speedtest-client

Java-library and command line interface (CLI) for testing internet bandwidth using speedtest.net
https://github.com/bernhardangerer/simple-speedtest-client

java java-11 java-library speedtest speedtest-cli

Last synced: 6 months ago
JSON representation

Java-library and command line interface (CLI) for testing internet bandwidth using speedtest.net

Awesome Lists containing this project

README

          

[![Maven Package](https://github.com/BernhardAngerer/simple-speedtest-client/actions/workflows/maven-publish.yml/badge.svg)](https://github.com/BernhardAngerer/simple-speedtest-client/actions/workflows/maven-publish.yml)
[![Maven Package](https://github.com/BernhardAngerer/simple-speedtest-client/actions/workflows/maven-verify.yml/badge.svg)](https://github.com/BernhardAngerer/simple-speedtest-client/actions/workflows/maven-verify.yml)

# ⏱️ Simple Speedtest-Client

A **Java library and CLI** tool for measuring internet bandwidth using [speedtest.net](https://www.speedtest.net/).
This is a lightweight Java-based implementation inspired by [Matt Martz’s speedtest-cli](https://github.com/sivel/speedtest-cli).

## βœ… Features

- Perform download, upload, and latency tests
- (Auto-) Select best server based on ping
- Share result as a Speedtest.net image
- Use as a CLI or embed as a Java library

## 🧰 Requirements
- Java 11+
- Maven

## βš™οΈ Build Instructions
To build the project and create a JAR file:
```bash
mvn clean install
```
The JAR will be located in target/, e.g.:
```bash
target/simple-speedtest-client-3.0.0.jar
```

## πŸš€ Usage

### πŸ’» CLI Usage
To run the CLI client:
```bash
java -jar simple-speedtest-client-3.0.0.jar
```

#### πŸ”§ CLI Options
```bash
usage: Optional parameters:
-h,--dedicatedServerHost Dedicated server host to run the tests
against
-l,--listServerHosts Provide a list of server hosts to run
the tests against
-nd,--noDownload Do not perform download test
-nu,--noUpload Do not perform upload test
-of,--outputFormat Output format of results (default:
console)
Available formats:
console β€” human-readable output to the
console
json β€” machine-readable JSON format
xml β€” machine-readable XML format
csv β€” comma-separated values format
-s,--share Generate and provide an URL to the
speedtest.net share results image

```

#### πŸ“ˆ Example Output
```bash
$ java -jar simple-speedtest-client-3.0.0.jar

Retrieving speedtest.net configuration...
Testing from Telekom Austria (193.81.52.87, AT)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by COSYS DATA GmbH (Vienna, AT) [9,46 km]: 18,00 ms
Testing download speed........................................
Download: 54,26 Mbits/s
Testing upload speed...................................................
Upload: 19,19 Mbits/s
```

### πŸ“š Java Library Usage
Use the library directly in Java:
```java
try {
// ⚠️ Note: This is a blocking call and may take up to 25 seconds
// depending on network latency, server selection, and transfer speed.
// Consider running it in a background thread if used in a GUI or server application.
SpeedtestResult result = SpeedtestController.runSpeedTest();

System.out.printf("Download: %.2f Mbps%n", result.getDownload().getRateInMbps());
System.out.printf("Upload: %.2f Mbps%n", result.getUpload().getRateInMbps());
System.out.printf("Latency: %.2f ms%n", result.getLatency().getLatency());
System.out.printf("Server: %s (%s, %s)%n",
result.getServer().getSponsor(),
result.getServer().getCity(),
result.getServer().getIsoAlpha2CountryCode());
} catch (SpeedtestException e) {
e.printStackTrace();
}
```

#### πŸ“ˆ Example Output
```bash
Download: 156,19 Mbps
Upload: 16,33 Mbps
Latency: 21,33 ms
Server: Timewarp IT Consulting GmbH (Vienna, AT)
```

## πŸ“¦ Dependency (Maven / Gradle)
Add the dependency via JitPack:
https://jitpack.io/private#BernhardAngerer/simple-speedtest-client/3.0.0