### Get Dota 2 Game Heroes (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_dota2_example.md Fetches a list of Dota 2 heroes, optionally filtered by locale. The example shows how to retrieve heroes and display their details. It takes a boolean for filtering and a String for the locale. ```java List heroes = econInterface.getGameHeroes(false, "en").get(); heroes.forEach(Dota2WebApiQueryEx::displayResult); ``` -------------------------------- ### Get Dota 2 Rarities (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_dota2_example.md Fetches a list of item rarities for a specified locale. The example demonstrates retrieving rarity data and displaying it. It takes a locale string as input. ```java List rarities = econInterface.getRarities("en").get(); rarities.forEach(Dota2WebApiQueryEx::displayResult); ``` -------------------------------- ### Get Package Details (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves detailed information about a specific package on the Steam store. It requires a package ID and returns a StorePackageDetails object. The output logs the package details. ```java StorePackageDetails packageDetails=storeFront.getPackageDetails(54029).join(); log.info("Package Details: {}",packageDetails); ``` -------------------------------- ### Get Featured Apps (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves a list of featured applications on the Steam store. This method does not require any input parameters and returns a StoreFeaturedApps object. The output logs the featured apps. ```java StoreFeaturedApps featuredApps=storeFront.getFeaturedApps().join(); log.info("Featured Apps: {}",featuredApps); ``` -------------------------------- ### Get Steam Econ Store Metadata Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches store metadata for a given game. This includes information relevant to the game's presence on the Steam store. The metadata is logged. ```java SteamEconItemsStoreMeta storeMedaData=steamEconItems.getStoreMetadata(440).join(); log.info("Store Meta Data: {}",storeMedaData); ``` -------------------------------- ### Get Dota 2 Top Live Games (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_dota2_example.md Retrieves a list of the top live Dota 2 games. The example shows fetching the top game based on a provided count. It returns a list of Dota2TopLiveGame objects. ```java List topLiveGames = matchInterface.getTopLiveGame(1).get(); topLiveGames.forEach(this::displayResult); ``` -------------------------------- ### Get Dota 2 League Listings (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_dota2_example.md Fetches a list of all currently active Dota 2 leagues. The output is a list of Dota2League objects. ```java List leagues = matchInterface.getLeagueListing().get(); leagues.forEach(this::displayResult); ``` -------------------------------- ### Get Player Profiles (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves profile information for a Steam player. It requires a Steam ID and returns a list of SteamPlayerProfile objects. The output logs the profile information. ```java steamUser.getPlayerProfiles(76561198010872093L).thenAccept(new Consumer>(){ @Override public void accept(List steamPlayerProfiles){ steamPlayerProfiles.forEach(p->log.info("{}",p)); } }).join(); ``` -------------------------------- ### Get User Stats for Game Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves the specific in-game statistics and achievements for a given player and game. ```APIDOC ## GET /steamUserStats/GetUserStatsForGame ### Description Retrieves the specific in-game statistics and achievements for a given player and game. ### Method GET ### Endpoint /steamUserStats/GetUserStatsForGame ### Parameters #### Query Parameters - **steamId** (long) - Required - The 64-bit Steam ID of the player. - **appId** (integer) - Required - The Steam Application ID. ### Response #### Success Response (200) - **achievements** (array) - A list of achievements the player has earned. - **stats** (object) - An object containing the player's in-game statistics. #### Response Example ```json { "achievements": [ { "name": "First Steps", "achieved": true } ], "stats": { "kills": 150, "deaths": 25 } } ``` ``` -------------------------------- ### Get Store App Details (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches detailed information about a specific application on the Steam store. It requires an app ID and returns a StoreAppDetails object. The output logs the retrieved store app details. ```java StoreAppDetails storeAppDetails=storeFront.getAppDetails(550).join(); log.info("Storefront App Details: {}",storeAppDetails); ``` -------------------------------- ### Get Dota 2 Pro Player List (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_dota2_example.md Fetches a list of professional Dota 2 players participating in fantasy leagues. The output is a list of Dota2FantasyProPlayerInfo objects. ```java List proPlayerInfos = fantasyInterface.getProPlayerList().get(); proPlayerInfos.forEach(Dota2WebApiQueryEx::displayResult); ``` -------------------------------- ### Get Steam App List Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves a list of all available Steam applications. It handles potential errors by logging them and returning an empty list. The result is processed by the displayResult method. ```java steamApps.getAppList().exceptionally(throwable->{ log.error("Error Occured",throwable); return new ArrayList<>(); }).thenAccept(this::displayResult).join(); ``` -------------------------------- ### Get Steam News for App Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches the latest news items for a specific Steam application. It iterates through the retrieved news items and logs the title of each. ```java steamNews.getNewsForApp(550).thenAccept(new Consumer>(){ @Override public void accept(List steamNewsItems){ steamNewsItems.forEach(new Consumer(){ @Override public void accept(SteamNewsItem steamNewsItem){ log.info("News Item: {}",steamNewsItem.getTitle()); } }); }).join(); ``` -------------------------------- ### Get Steam Economy Asset Prices Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches pricing information for in-game assets for a given game. It processes the list of asset prices and logs each item's details. ```java steamEconomy.getAssetPrices(730).thenAccept(new Consumer>(){ @Override public void accept(List steamAssetPriceInfos){ log.info("Retrieved Steam Asset Price Info for CSGO"); steamAssetPriceInfos.forEach(new Consumer(){ @Override public void accept(SteamAssetPriceInfo steamAssetPriceInfo){ log.info(" {}",steamAssetPriceInfo); } }); } }).join(); ``` -------------------------------- ### Get Dota 2 Broadcaster Info (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_dota2_example.md Retrieves information about Dota 2 broadcasters based on their Steam ID and a game ID. The output is a Dota2BroadcasterInfo object. ```java Dota2BroadcasterInfo bInfo = streamInterface.getBroadcasterInfo(292948090, -1).get(); log.info("Broadcaster Info: {}", bInfo); ``` -------------------------------- ### Get Supported API List from Web API Util (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves a list of all supported interfaces and their methods available through the Steam Web API. This is useful for discovering available API functionalities. Requires a SteamWebApiClient instance. ```java public class WebApiUtilExample { public static void main(String[] args) throws Exception { try (SteamWebApiClient client = new SteamWebApiClient("")) { SteamWebAPIUtil service = new SteamWebAPIUtil(client); List apiInterfaceList = service.getSupportedApiList().join(); for (ApiInterface apiInterface : apiInterfaceList) { System.out.printf("Interface: %s (Methods: %d)%n", apiInterface.getName(), apiInterface.getMethods().size()); } } } } ``` -------------------------------- ### Get Server Info from Web API Util (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches current server information, including the server's current time. This can be used for time synchronization or checking server status. Requires a SteamWebApiClient instance. ```java public class WebApiUtilExample { public static void main(String[] args) throws Exception { try (SteamWebApiClient client = new SteamWebApiClient("")) { SteamWebAPIUtil service = new SteamWebAPIUtil(client); ServerInfo info = service.getServerInfo().join(); System.out.printf("Time: %d, Time String: %s%n", info.getServertime(), info.getServerTimeString()); } } } ``` -------------------------------- ### Get Sale Details (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches details about ongoing sales on the Steam store. It takes a sale filter (e.g., 0 for all sales) as input and returns a StoreSaleDetails object. The output logs the sale details. ```java StoreSaleDetails storeSaleDetails=storeFront.getSaleDetails(0).join(); log.info("Sale Details: {}",storeSaleDetails); ``` -------------------------------- ### Get Steam Servers by Address Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches a list of game servers running at a specified IP address. Errors are logged, and an empty list is returned in case of failure. The addresses of the found servers are then logged. ```java steamApps.getServersAtAddress(InetAddress.getByName("103.28.55.237")) .exceptionally(throwable->{ log.error("Error occured",throwable); return new ArrayList<>(); }) .thenAccept(steamServers->{steamServers.stream().forEachOrdered(steamServer->log.info("Server: {}",steamServer.getAddr()));}) .join(); ``` -------------------------------- ### Get User Group List (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches the list of Steam groups a user is a part of. It requires a Steam ID and returns a list of SteamGroupId objects. The output logs the group ID for each group. ```java steamUser.getUserGroupList(76561198010872093L).thenAccept(steamGroupIds->{ steamGroupIds.forEach(new Consumer(){ @Override public void accept(SteamGroupId steamGroupId){ log.info("Steam Group Id: {}",steamGroupId.getGroupId()); } }); }).join(); ``` -------------------------------- ### Get Steam Economy Asset Class Info Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves detailed information for specific in-game asset classes. It takes the Game ID and multiple asset IDs as input and logs the information for each class. ```java steamEconomy.getAssetClassInfo(730,"en",186150629L,506856209L,506856210L,903185406L, 613589849L,613589850L,613589851L,613589852L,613589853L,613589854L,613589855L).thenAccept(new Consumer>(){ @Override public void accept(Map stringSteamAssetClassInfoMap){ stringSteamAssetClassInfoMap.forEach((classId,classInfo)->{ log.info("ID: {}, Info: {}",classId,classInfo); }); }).join(); ``` -------------------------------- ### Get Steam Econ Player Items Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves a list of in-game items owned by a specific Steam user for a given game. Requires the Game ID, SteamID64, and API version. The retrieved items are then logged. ```java List playerItems=steamEconItems.getPlayerItems(730,76561197960761020L,SteamEconItems.VERSION_1).get(); log.info("Player Items: {}",playerItems); ``` -------------------------------- ### Get Popular Tags from Steam Store Service (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches a list of popular tags for a given language from the Steam store. This can be used to display trending or commonly used tags. Requires a SteamWebApiClient instance. ```java public class SteamStoreExample { public static void main(String[] args) throws Exception { try (SteamWebApiClient client = new SteamWebApiClient("")) { SteamStoreService service = new SteamStoreService(client); List popularTags = service.getPopularTag("english").join(); popularTags.forEach(tag -> System.out.printf("\tId: %d, Name: %s%n", tag.getTagId(), tag.getName())); } } } ``` -------------------------------- ### Get Dota 2 Match Details (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_dota2_example.md Retrieves detailed information for a specific Dota 2 match using its match ID. The result includes match data and player details within that match. ```java Dota2MatchDetails matchDetails = matchInterface.getMatchDetails(2753811554L).get(); log.info("Match Details: {}", matchDetails); matchDetails.getPlayers().forEach(this::displayResult); ``` -------------------------------- ### Get Game Server Account Information Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves detailed information about game server accounts. This method fetches a list of accounts and their associated server details. The response includes a GameServerAccount object containing a list of GameServerAccountDetail objects. ```java class WebApiExample { public static void main(String[] args) throws Exception { try (GameServersService gameServersService = new GameServersService(client)) { GameServerAccount accountInfo = gameServersService.getAccountList().join(); System.out.println(accountInfo); for (GameServerAccountDetail detail : accountInfo.getServers()) { System.out.println(detail); } } } } ``` -------------------------------- ### Get Apps from Steam Community Service (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves details for a list of Steam applications from the community service, including their names and icons. This function is useful for displaying basic app information. Requires a SteamWebApiClient instance and a list of app IDs. ```java public class SteamCommunityExample { public static void main(String[] args) throws Exception { try (SteamWebApiClient client = new SteamWebApiClient("")) { SteamCommunityService service = new SteamCommunityService(client); List communityApps = service.getApps(550, 440, 730).join(); for (SteamCommunityApp app : communityApps) { System.out.printf("App Id: %d, Name: %s, Icon: %s%n", app.getAppid(), app.getName(), app.getIcon()); } } } } ``` -------------------------------- ### Get Dota 2 Game Items (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_dota2_example.md Retrieves a list of all available game items from the Dota 2 Economy interface. It fetches the data and then iterates through the list to display each item. No specific dependencies are mentioned beyond the econInterface. ```java List gameItems = econInterface.getGameItems().get(); log.info("All of the game items.."); gameItems.forEach(Dota2WebApiQueryEx::displayResult); ``` -------------------------------- ### Get Dota 2 Match History by Sequence Number (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_dota2_example.md Retrieves a list of Dota 2 match details based on a sequence number range. This allows fetching matches in batches. It requires a start and count parameter. ```java List matchDetailsBySeq = matchInterface.getMatchHistoryBySequenceNum(1, 10).get(); matchDetailsBySeq.forEach(this::displayResult); ``` -------------------------------- ### Authenticate with Source Server using Java Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/source_rcon_example.md Demonstrates basic authentication with a Source server using the SourceRconClient. It shows how to create a client, connect to a server address, authenticate, and check the authentication status. Handles potential RconAuthException. ```java import java.net.InetSocketAddress; import com.ibasco.agql.protocols.valve.source.query.rcon.SourceRconClient; import com.ibasco.agql.protocols.valve.source.query.rcon.SourceRconAuthResponse; import com.ibasco.agql.protocols.valve.source.query.rcon.exceptions.RconAuthException; class RconAuthExample { public static void main(String[] args) throws Exception { try (SourceRconClient client = new SourceRconClient()) { InetSocketAddress address = new InetSocketAddress("192.168.1.10", 27015); SourceRconAuthResponse response = client.authenticate(address, password.getBytes()).join(); //Check authenticated flag if (!response.isAuthenticated()) { System.err.printf("Failed to authenticate with server (Reason: %s, Code: %s)%n", response.getReason(), response.getReasonCode().name()); return; } //do something here... System.out.println("Successfully authenticated with server"); } catch (RconAuthException ex) { System.err.printf("Failed to authenticate with server (Reason: %s)%n", ex.getReason()); ex.printStackTrace(System.err); } } } ``` -------------------------------- ### Send Command to Source Server using Java Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/source_rcon_example.md Illustrates how to send a command to a Source server after authentication. It shows the process of creating a client, connecting, authenticating (commented out for brevity), and then executing a command like 'status'. It retrieves and prints the command result. Handles potential RconException. ```java import java.net.InetSocketAddress; import com.ibasco.agql.protocols.valve.source.query.rcon.SourceRconClient; import com.ibasco.agql.protocols.valve.source.query.rcon.SourceRconCmdResponse; import com.ibasco.agql.protocols.valve.source.query.rcon.exceptions.RconException; class RconCmdExample { public static void main(String[] args) throws Exception { try (SourceRconClient client = new SourceRconClient()) { InetSocketAddress address = new InetSocketAddress("192.168.1.10", 27015); //1. authenticate.... //.... //2. send command SourceRconCmdResponse response = client.execute(address, "status").join(); System.out.printf("Got response from server '%s': %s%n", response.getAddress(), response.getResult()); } catch (RconException ex) { System.err.printf("Failed to authenticate with server (Reason: %s)%n", ex.getReason()); ex.printStackTrace(System.err); } } } ``` -------------------------------- ### Asynchronously execute multiple help requests and synchronize in Java Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/introduction.md This example improves upon the previous one by executing multiple 'help ' requests asynchronously. It uses a synchronization barrier, specifically `Phaser`, to wait for all asynchronous requests to complete before proceeding. This approach is more efficient for handling numerous concurrent operations. ```java import java.util.concurrent.CompletableFuture; import java.util.function.Function; public class RecommendedExampleTwo { ``` -------------------------------- ### Get Schema For Game Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches the schema (achievements and stats) for a specified Steam App ID. ```APIDOC ## GET /steamUserStats/GetSchemaForGame ### Description Fetches the schema (achievements and stats) for a specified Steam App ID. ### Method GET ### Endpoint /steamUserStats/GetSchemaForGame ### Parameters #### Query Parameters - **appId** (integer) - Required - The Steam Application ID. ### Response #### Success Response (200) - **achievementSchemaList** (array) - A list of achievement schema objects. - **name** (string) - The name of the achievement schema. - **statsSchemaList** (array) - A list of stats schema objects. - **name** (string) - The name of the stats schema. #### Response Example ```json { "achievementSchemaList": [ { "name": "First Steps" }, { "name": "Master Explorer" } ], "statsSchemaList": [ { "name": "Kills" }, { "name": "Deaths" } ] } ``` ``` -------------------------------- ### Configure SourceQueryClient with Options Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/configuration.md Demonstrates how to build custom configuration options for a SourceQueryClient using SourceQueryOptions.builder(). It shows how to set various options like connection pooling, retry delay, rate limiting, and read timeout. This example requires the `SourceQueryOptions`, `GeneralOptions`, `ConnectOptions`, and `FailsafeOptions` classes. ```java class ConfigExample { public static void main(String[] args) { //SourceRconOptions options = SourceRconOptions.builder() //MasterServerOptions options = MasterServerOptions.builder() //HttpOptions options = HttpOptions.builder(); SourceQueryOptions options = SourceQueryOptions.builder() .option(GeneralOptions.CONNECTION_POOLING, false) //disable connection pooling for source queries .option(ConnectOptions.FAILSAFE_RETRY_DELAY, 5000L) //change retry duration to 5 seconds if connection to the game server fails .option(FailsafeOptions.FAILSAFE_RATELIMIT_ENABLED, true) //turn on rate limiting for server queries .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH) //change rate limit strategy for source queries .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, customExecutor) //provide a custom executor service .option(GeneralOptions.READ_TIMEOUT, 5000) //change socket read timeout duration to 5 seconds .build(); SourceQueryClient client = new SourceQueryClient(options); //... } } ``` -------------------------------- ### Execute cvarlist and parse output asynchronously in Java Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/introduction.md This example demonstrates executing the 'cvarlist' command and asynchronously parsing its output using `thenApplyAsync`. It shows how to authenticate with an RCON client, execute commands, and process results while avoiding blocking the event loop. Dependencies include `java.util.concurrent.CompletableFuture` and `java.util.function.Function`. ```java import java.util.concurrent.CompletableFuture; import java.util.function.Function; import java.util.regex.Pattern; import java.util.List; import java.util.ArrayList; import java.net.InetSocketAddress; import org.apache.commons.lang3.StringUtils; public class RecommendedExampleOne { private static final Pattern cvarlistParser = Pattern.compile("(?\\S+)\\s*:\\s?(?\\S+)?\\s*:(?.*):(?.*)$", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); private static class ConVar { private final String name; private final String value; private final String[] types; private final String description; private ConVar(String name, String value, String[] types, String description) { this.name = name; this.value = value; this.types = types; this.description = description; } private String getName() { return name; } private String getValue() { return value; } private String[] getTypes() { return types; } private String getDescription() { return description; } } public static void main(String[] args) throws Exception { new RecommendedExampleOne().run(); } private void run() throws Exception { InetSocketAddress address = new InetSocketAddress("192.168.1.10", 27016); try (SourceRconClient client = new SourceRconClient()) { //authenticate SourceRconAuthResponse authResponse = client.authenticate(address, "".getBytes()).join(); if (!authResponse.isAuthenticated()) throw new Exception(authResponse.getReason()); //Example //1. execute 'cvarlist' //2. parse 'cvarlist' output with regex //3. transform each convar into ConVar class and add to list //4. return list List cvarList = client.execute(address, "cvarlist") .thenApplyAsync(out -> parseOutput(client, out)) //THIS IS A LONG RUNNING TASK. Call thenApplyAsync() so it wont block the event-loop. .join(); //block until the operation is complete System.out.printf("Processed a total of %d cvars%n", cvarList.size()); } } private List parseOutput(SourceRconClient client, SourceRconCmdResponse response) { String cvarlistOutput = response.getResult(); Matcher matcher = cvarlistParser.matcher(cvarlistOutput); List conVarList = new ArrayList<>(); while (matcher.find()) { String name = matcher.group("name"); String value = matcher.group("value"); String[] types = StringUtils.splitPreserveAllTokens(matcher.group("group"), ","); String description = matcher.group("description"); ConVar conVar = new ConVar(name, value, types, description); conVarList.add(conVar); Console.colorize(true).green("[%s]", Thread.currentThread().getName()).white(": %s = %s", conVar.getName(), conVar.getValue()).println(); //Obtain additional information about the cvar via calling 'help ' (Calling join() will block the current event loop thread) SourceRconCmdResponse helpResponse = client.execute(response.getAddress(), String.format("help %s", name.trim())).join(); //parse cvarHelpRes and update ConVar String helpOutput = helpResponse.getResult(); //parse helpOutput here.... } return conVarList; } } ``` -------------------------------- ### Get App List from Steam Store Service (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches a paginated list of Steam applications. It demonstrates how to retrieve the first page of apps and then continue fetching subsequent pages using the last app ID from the previous response. Requires a SteamWebApiClient instance. ```java public class SteamStoreExample { public static void main(String[] args) throws Exception { try (SteamWebApiClient client = new SteamWebApiClient("")) { SteamStoreService service = new SteamStoreService(client); SteamStoreAppResponse response = service.getAppList(10).join(); response.getApps().forEach(app -> System.out.printf("\t[Page: 1] App: %s%n", app.getName())); response = service.getAppList(response.getLastAppid(), 10).join(); response.getApps().forEach(app -> System.out.printf("\t[Page: 2] App: %s%n", app.getName())); } } } ``` -------------------------------- ### Web API Request Example (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_general_usage.md Demonstrates how to initialize a Web API client with an API token and create an interface for making requests. The client requires an API token for authentication and should be closed when no longer needed. It's recommended to reuse client instances to minimize overhead. ```java class WebApiGeneralUsage { public static void main(String[] args) throws Exception { //API Token String token = ""; //Create and initialize client try (CocWebApiClient client = new CocWebApiClient(token)) { //Create and initialize the interface, passing the client as argument for the default constructor CocClans clans = new CocClans(client); //Invoke the request CompletableFuture> clanDetailsFuture = clans.searchClans(criteria); //Do something with clanDetailsFuture... } } } ``` -------------------------------- ### Get Player Achievements Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches the list of achievements for a specific player and game, indicating whether each achievement has been achieved. ```APIDOC ## GET /steamUserStats/GetPlayerAchievements ### Description Fetches the list of achievements for a specific player and game, indicating whether each achievement has been achieved. ### Method GET ### Endpoint /steamUserStats/GetPlayerAchievements ### Parameters #### Query Parameters - **steamId** (long) - Required - The 64-bit Steam ID of the player. - **appId** (integer) - Required - The Steam Application ID. ### Response #### Success Response (200) - **achievements** (array) - A list of player achievement objects. - **name** (string) - The name of the achievement. - **achieved** (boolean) - True if the player has achieved this achievement, false otherwise. #### Response Example ```json { "achievements": [ { "name": "First Steps", "achieved": true }, { "name": "Master Explorer", "achieved": false } ] } ``` ``` -------------------------------- ### Get Total Number of Current Players for Game Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves the total number of players currently playing a specific game. ```APIDOC ## GET /steamUserStats/GetNumberOfCurrentPlayers ### Description Retrieves the total number of players currently playing a specific game. ### Method GET ### Endpoint /steamUserStats/GetNumberOfCurrentPlayers ### Parameters #### Query Parameters - **appId** (integer) - Required - The Steam Application ID. ### Response #### Success Response (200) - **playerCount** (integer) - The total number of players currently in the game. #### Response Example ```json { "playerCount": 15000 } ``` ``` -------------------------------- ### Install from Source using Maven Source: https://github.com/ribasco/async-gamequery-lib/blob/master/README.md Clone the Async GameQuery Lib repository from GitHub and build it locally using Maven. This command installs all modules into your local Maven repository. ```bash git clone https://github.com/ribasco/async-gamequery-lib.git cd async-gamequery-lib mvn install ``` -------------------------------- ### Create Game Server Account Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Creates a new game server account using the GameServersService. This operation requires an application ID and an account name. The method returns a CompletableFuture that resolves to a NewGameServerAccount object upon successful creation. ```java class WebApiExample { public static void main(String[] args) throws Exception { try (GameServersService gameServersService = new GameServersService(client)) { NewGameServerAccount newAccount = gameServersService.createAccount(550, "Test").join(); System.out.println(newAccount); } } } ``` -------------------------------- ### Get Global Achievement Percentage for App Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves the global percentage of players who have achieved each achievement for a given Steam App ID. ```APIDOC ## GET /steamUserStats/GetGlobalAchievementPercentagesForApp ### Description Retrieves the global percentage of players who have achieved each achievement for a given Steam App ID. ### Method GET ### Endpoint /steamUserStats/GetGlobalAchievementPercentagesForApp ### Parameters #### Query Parameters - **appId** (integer) - Required - The Steam Application ID. ### Response #### Success Response (200) - **achievements** (array) - A list of achievement objects, each containing name and percentage. - **name** (string) - The name of the achievement. - **percentage** (number) - The percentage of players who have achieved this. #### Response Example ```json { "achievements": [ { "name": "First Steps", "percentage": 95.5 }, { "name": "Master Explorer", "percentage": 10.2 } ] } ``` ``` -------------------------------- ### Instantiate SourceQueryClient and Get Server Info (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/README.md Demonstrates how to instantiate the SourceQueryClient using a try-with-resources block and retrieve server information asynchronously. The client implements java.io.Closeable, ensuring proper resource management. ```java import com.ibasco.agql.core.query.SourceQueryClient; import com.ibasco.agql.core.query.SourceQueryOptions; import com.ibasco.agql.core.query.SourceServer; import com.ibasco.agql.core.util.GeneralOptions; import java.net.InetSocketAddress; public class Example { public static void main(String[] args) { SourceQueryOptions queryOptions = SourceQueryOptions.builder() .build(); //You can instantiate the client from the try-with block as it implements the java.io.Closeable interface try (SourceQueryClient client = new SourceQueryClient(queryOptions)) { InetSocketAddress address = new InetSocketAddress("192.168.60.1", 27016); SourceServer info = client.getInfo(address).join().getResult(); System.out.printf("INFO: %s\n", info); } } } ``` -------------------------------- ### Steam Apps API Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Provides methods related to Steam Apps, including fetching app lists and server information. ```APIDOC ## GET /steam/apps ### Description Retrieves a list of all available Steam applications. ### Method GET ### Endpoint /steam/apps ### Parameters None ### Request Example None ### Response #### Success Response (200) - **appList** (array) - A list of Steam application objects. - **appId** (integer) - The unique identifier for the application. - **name** (string) - The name of the application. #### Response Example ```json { "appList": [ { "appId": 440, "name": "Team Fortress 2" }, { "appId": 550, "name": "Half-Life 2: Deathmatch" } ] } ``` ``` ```APIDOC ## GET /steam/apps/servers ### Description Retrieves a list of game servers based on a specified IP address. ### Method GET ### Endpoint /steam/apps/servers #### Query Parameters - **address** (string) - Required - The IP address to query for servers. ### Request Example ``` GET /steam/apps/servers?address=103.28.55.237 ``` ### Response #### Success Response (200) - **serverList** (array) - A list of server information objects. - **addr** (string) - The IP address and port of the server. - **gamePort** (integer) - The game port of the server. - **specPort** (integer) - The spectator port of the server. - **steamId** (long) - The Steam ID of the server. - **queryPort** (integer) - The query port of the server. - **name** (string) - The name of the server. - **players** (integer) - The current number of players on the server. - **maxPlayers** (integer) - The maximum number of players allowed on the server. - **botPlayers** (integer) - The number of bot players on the server. - **map** (string) - The current map of the server. - **os** (string) - The operating system of the server. - **password** (boolean) - Indicates if the server is password protected. - **version** (string) - The version of the game server. - **gametype** (string) - The type of game being played on the server. #### Response Example ```json { "serverList": [ { "addr": "103.28.55.237:27015", "gamePort": 27015, "specPort": 27020, "steamId": 76561197960761020, "queryPort": 27015, "name": "My Awesome Server", "players": 10, "maxPlayers": 32, "botPlayers": 0, "map": "de_dust2", "os": "l", "password": false, "version": "1.37.5.6", "gametype": "FFA" } ] } ``` ``` ```APIDOC ## GET /steam/apps/server/updateStatus ### Description Checks the update status of a specific game server. ### Method GET ### Endpoint /steam/apps/server/updateStatus #### Query Parameters - **appId** (integer) - Required - The ID of the application. - **serverQueryPort** (integer) - Required - The query port of the server. ### Request Example ``` GET /steam/apps/server/updateStatus?appId=2146&serverQueryPort=550 ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the update status check was successful. - **message** (string) - A message describing the update status. - **requiredVersion** (integer) - The required version for the server. #### Response Example ```json { "success": true, "message": "Server is up to date.", "requiredVersion": 100 } ``` ``` -------------------------------- ### Get Dota 2 Match History (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_dota2_example.md Fetches the latest match history for Dota 2. The result is a Dota2MatchHistory object containing summary information. ```java Dota2MatchHistory matchHistory = matchInterface.getMatchHistory().get(); log.info("Match History : {}", matchHistory); ``` -------------------------------- ### Get Steam Econ Schema URL Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Retrieves the URL for the item schema of a specific game. This URL can be used to download the schema directly. The URL is then logged. ```java String schemaUrl=steamEconItems.getSchemaUrl(440).join(); log.info("Schema URL : {}",schemaUrl); ``` -------------------------------- ### Get Steam Econ Schema Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_steam_example.md Fetches the item schema for a given game. The schema contains information about all items available in the game. The result is joined and logged. ```java SteamEconSchema schema=steamEconItems.getSchema(440).join(); log.info("Schema: {}",schema); ``` -------------------------------- ### Enable and Configure Rate Limiting for Server Queries (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/source_query_example.md This Java code snippet demonstrates how to enable and configure rate limiting for server queries using the async-gamequery-lib. It shows how to set options such as enabling the rate limiter, choosing the rate limit type (SMOOTH), and defining the period, maximum executions, and maximum wait time. The example sends multiple asynchronous queries and waits for their completion, illustrating the practical application of rate limiting. ```java import com.ibasco.agql.core.enums.RateLimitType; import com.ibasco.agql.core.util.FailsafeOptions; import com.ibasco.agql.protocols.valve.source.query.SourceQueryClient; import com.ibasco.agql.protocols.valve.source.query.SourceQueryOptions; import com.ibasco.agql.protocols.valve.source.query.info.SourceQueryInfoResponse; import com.ibasco.agql.protocols.valve.source.query.info.SourceServer; import java.net.InetSocketAddress; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; public class QueryTest { private final CountDownLatch latch = new CountDownLatch(50); private final AtomicInteger counter = new AtomicInteger(); public static void main(String[] args) throws Exception { new QueryTest().run(); } private void run() throws Exception { //sv_max_queries_sec_global 5 // Maximum queries per second to respond to from anywhere. (Default: 60) //sv_max_queries_sec 5 // Maximum queries per second to respond to from a single IP address. (Default 3.0) //sv_max_queries_window 200 // Window over which to average queries per second averages. (Default: 30) SourceQueryOptions options = SourceQueryOptions.builder() //enable rate limiting .option(FailsafeOptions.FAILSAFE_RATELIMIT_ENABLED, true) //Select rate limit strategy (BURST or SMOOTH) .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH) .option(FailsafeOptions.FAILSAFE_RATELIMIT_PERIOD, 5000L) .option(FailsafeOptions.FAILSAFE_RATELIMIT_MAX_EXEC, 10L) .option(FailsafeOptions.FAILSAFE_RATELIMIT_MAX_WAIT_TIME, 10000L) .option(FailsafeOptions.FAILSAFE_RETRY_ENABLED, false) .option(FailsafeOptions.FAILSAFE_RETRY_BACKOFF_ENABLED, false) .build(); InetSocketAddress address = new InetSocketAddress("192.168.50.6", 27016); //Send 50 requests asynchronously try (SourceQueryClient client = new SourceQueryClient(options)) { for (int i = 0; i < latch.getCount(); i++) { client.getInfo(address).whenComplete(this::printResponse); } //wait until we have received everything System.out.println("Waiting for all futures to complete"); latch.await(); System.out.println("Done"); } } private void printResponse(SourceQueryInfoResponse response, Throwable error) { try { if (error != null) { error.printStackTrace(System.err); return; } assert response.getAddress() == response.getResult().getAddress(); SourceServer info = response.getResult(); System.out.printf("[%s] %03d Got response from '%s' = %s (%d/%d)%n", Thread.currentThread().getName(), counter.incrementAndGet(), response.getAddress(), info.getName(), info.getNumOfPlayers(), info.getMaxPlayers()); } finally { latch.countDown(); } } } ``` -------------------------------- ### Get Dota 2 Live League Games (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/webapi_dota2_example.md Retrieves details for all currently live league games in Dota 2. The result is a list of Dota2LiveLeagueGame objects. ```java List gameDetails = matchInterface.getLiveLeagueGames().get(); gameDetails.forEach(this::displayResult); ``` -------------------------------- ### Initialize and Use Steam Web API Client in Java Source: https://context7.com/ribasco/async-gamequery-lib/llms.txt Demonstrates how to initialize the `SteamWebApiClient` with an API key and utilize various interfaces to fetch data like player profiles, friend lists, game statistics, news, and app lists. It uses Java's `CompletableFuture` for asynchronous operations. ```java import com.ibasco.agql.protocols.valve.steam.webapi.SteamWebApiClient; import com.ibasco.agql.protocols.valve.steam.webapi.interfaces.*; import com.ibasco.agql.protocols.valve.steam.webapi.pojos.*; import java.util.List; String apiKey = "YOUR_STEAM_API_KEY"; try (SteamWebApiClient client = new SteamWebApiClient(apiKey)) { // Initialize API interfaces SteamUser steamUser = new SteamUser(client); SteamUserStats steamUserStats = new SteamUserStats(client); SteamPlayerService playerService = new SteamPlayerService(client); SteamNews steamNews = new SteamNews(client); SteamApps steamApps = new SteamApps(client); long steamId = 76561198010872093L; int csgoAppId = 730; // Get player profile List profiles = steamUser.getPlayerProfiles(steamId).join(); profiles.forEach(profile -> System.out.printf("Player: %s, Level: Profile URL: %s%n", profile.getPersonaName(), profile.getProfileUrl())); // Get friend list List friends = steamUser.getFriendList(steamId, "friend").join(); System.out.println("Friends count: " + friends.size()); // Get current player count for a game Integer playerCount = steamUserStats.getNumberOfCurrentPlayers(csgoAppId).join(); System.out.println("Current CS:GO players: " + playerCount); // Get player achievements List achievements = steamUserStats.getPlayerAchievements(steamId, csgoAppId).join(); long unlockedCount = achievements.stream().filter(a -> a.getAchieved() > 0).count(); System.out.printf("Achievements: %d/%d unlocked%n", unlockedCount, achievements.size()); // Get recently played games List recentGames = playerService.getRecentlyPlayedGames(steamId, 10).join(); recentGames.forEach(game -> System.out.printf("Recently played: %s (%d minutes)%n", game.getName(), game.getTotalPlaytime())); // Get news for an app List news = steamNews.getNewsForApp(csgoAppId).join(); news.stream().limit(5).forEach(item -> System.out.printf("News: %s - %s%n", item.getTitle(), item.getUrl())); // Get all Steam apps List apps = steamApps.getAppList().join(); System.out.println("Total Steam apps: " + apps.size()); } ``` -------------------------------- ### Start Source Log Listener Service (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/site/markdown/examples/source_log_example.md Demonstrates how to start the SourceLogListenService to receive real-time log events. It requires an InetSocketAddress for the server and a callback function to process incoming log data. The service runs until explicitly closed. ```java import java.net.InetSocketAddress; public class SourceLogListenerExample extends BaseExample { private static final Logger log = LoggerFactory.getLogger(SourceLogListenerExample.class); public static void main(String[] args) throws Exception { InetSocketAddress address = new InetSocketAddress("192.168.1.10", 27015); SourceLogListenService logService = new SourceLogListenService(addres, SourceLogListenerExample::processLogData); CompletableFuture f = logService.listen(); f.join(); System.out.println("Log service has been closed"); } private static void processLogData(SourceLogEntry message) { System.out.printf("\u001B[36m%s:\u001B[0m %s\n", message.getSourceAddress(), message.getMessage()); } } ``` -------------------------------- ### Configure Source Query Client with Custom Executor and Rate Limiting (Java) Source: https://github.com/ribasco/async-gamequery-lib/blob/master/README.md This example demonstrates how to configure a SourceQueryClient in Java. It shows how to set custom Failsafe options, specifically changing the rate limiting method to BURST, and how to provide a custom Thread Executor Service. The user is responsible for managing the lifecycle of the provided executor. ```java import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.ibasco.agql.core.enums.RateLimitType; import com.ibasco.agql.core.options.FailsafeOptions; import com.ibasco.agql.core.options.GeneralOptions; import com.ibasco.agql.core.options.SourceQueryOptions; public class BlockingQueryExample { //Use a custom executor. This is not really necessary as the library //provides it's own default executor, this only serves an example. ExecutorService customExecutor = Executors.newCachedThreadPool(); public static void main(String[] args) { // - Change rate limiting method to BURST // - Used a custom executor for query client. We are responsible for shutting down this executor, not the library. SourceQueryOptions queryOptions = SourceQueryOptions.builder() .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.BURST) .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, customExecutor) .build(); } } ```