Coder Social home page Coder Social logo

steam-web-api-client's Introduction

GitHub License Maven Central

Steam Web Api Client

This library provides a simple way to interact with Steam Web Api through Java.

Features

  • Query Steam Workshop
  • Get information about users/players.
  • And more...

Prerequisites

Usage

Maven

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.

Maven

<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>

Gradle

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
}

Code Examples

Creating the SteamWebApiClient

String steamApiKey = "123mykey123"; // Your Steam Web Api Key
SteamWebApiClient steamWebApiClient = new SteamWebApiClient(steamApiKey);

// 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 = new SteamWebApiClient();

Configuring the underlying HttpClient and ObjectMapper

// 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 = new SteamWebApiClient(steamApiKey, httpClient, objectMapper);

Example workshop search

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);

Get recently played games by a user

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);

Credits

Lead Developer - Aquerr

Developer - mateo9x

License

Apache License, Version 2.0

steam-web-api-client's People

Contributors

aquerr avatar mateo9x avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

steam-web-api-client's Issues

Implementation for IGameServersService - CreateAccount

This endpoint allows creation of so called GSLT (Game Server Login Tokens) used to host dedicated server without providing real account credentials and allowing you to play on such server simultaneously as you host it.

Parameter Type Description
key string   Access key
appid uint32   The app to use the account for
memo string   The memo/description to set on the new account

Implementation for IGameServersService - GetAccountPublicInfo

This endpoint seems to be returning the steamid of GSLT itself + the app id.

Request:

Parameter Type Description
key string The API KEY
steamid uint64 The steam id of the GSLT

Response:

Parameter Type Description
steamid uint64 The steam id of the GSLT
appid uint32 The id of the app that the corresponding GSLT is for

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.