This library provides a simple way to interact with Steam Web Api through Java.
- Query Steam Workshop
- Get information about users/players.
- And more...
- Java 11
- Jackson (databind)
- Steam Web Api Access Token (required for most endpoints)
steam-web-api-client
is available at Maven Central.
<dependencies>
<dependency>
<groupId>io.github.aquerr</groupId>
<artifactId>steam-web-api-client</artifactId>
<version>${steam-web-api-client.version}</version>
</dependency>
</dependencies>
It is also possible to get the library via Jitpack.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.Aquerr</groupId>
<artifactId>steam-web-api-client</artifactId>
<version>main-SNAPSHOT</version>
</dependency>
</dependencies>
Groovy DSL:
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'io.github.aquerr:steam-web-api-client:version' // <-- Via Maven Central
implementation 'com.github.Aquerr:steam-web-api-client:main-SNAPSHOT' // <-- Via Jitpack
}
Kotlin DSL:
repositories {
mavenCentral()
maven("https://jitpack.io")
}
dependencies {
implementation("io.github.aquerr:steam-web-api-client:version") // <-- Via Maven Central
implementation("com.github.Aquerr:steam-web-api-client:main-SNAPSHOT") // <-- Via Jitpack
}
String steamApiKey = "123mykey123"; // Your Steam Web Api Key
SteamWebApiClient steamWebApiClient = SteamWebApiClient.builder().apiKey(steamApiKey).build();
// As because api key is not required for all endpoints, this is also valid.
// Remember that endpoints that require api key will not work with such setup.
SteamWebApiClient steamWebApiClient = SteamWebApiClient.builder().build();
// Default HttpClient used by the library has timeout set to 5 seconds.
// Let's increase that timeout.
HttpClient httpClient = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
// Default ObjectMapper does not fail on unknown properties, so let's change it to fail!
ObjectMapper objectMapper = new ObjectMapper()
.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
String steamApiKey = "123mykey123"; // Your Steam Web Api Key
SteamWebApiClient steamWebApiClient = SteamWebApiClient.builder().apiKey(steamApiKey)
.httpClient(httpClient)
.objectMapper(objectMapper)
.build();
WorkShopQueryFilesRequest request = WorkShopQueryFilesRequest.builder()
.appId(730) // Counter Strike App Id
.searchText("Adventure COOP Maps")
.fileType(WorkShopQueryFilesRequest.PublishedFileInfoMatchingFileType.ITEMS)
.queryType(WorkShopQueryFilesRequest.PublishedFileQueryType.RANKED_BY_TOTAL_UNIQUE_SUBSCRIPTIONS)
.key(steamApiKey) // Not required if you set up your SteamWebApiClient with an API Key.
.numPerPage(10) // Number of items per page.
.cursor("*") // We should set this to * for first request according to Steam Web Api Docs.
// After that use cursor from response that will get you next page.
.returnPreviews(true) // If preview images should be returned.
.build();
WorkShopQueryResponse response = steamWebApiClient.getSteamPublishedFileWebApiClient().queryFiles(request);
Note: If looked up user has private profile, and you are not friends, then the response will contain an empty list.
PlayerRecentlyPlayedGamesRequest request = PlayerRecentlyPlayedGamesRequest.builder()
.steamId(1234L)
.count(10)
.build()
PlayerRecentlyPlayedGamesResponse response = steamWebApiClient.getPlayerWebApiClient().getRecentlyPlayedGames(request);
Lead Developer - Aquerr
Developer - mateo9x