Previously developed as
steam_api. It is not related to thesteam_apigem on RubyGems.
A Ruby gem for interacting with the Steam Web API. It returns plain Ruby objects (Data) with snake_case fields, such as game details, player information, and achievements, and its only dependency is Faraday.
- Fetch game details, news, and global achievements.
- Retrieve player summaries, friends, achievements, and game stats.
- Get owned games, recently played games, and Steam levels.
- Supports both authenticated and unauthenticated requests.
- Easy-to-use client configuration.
Add the gem to your application's Gemfile:
gem "steam_api_client"and run bundle install. Or let Bundler do both:
$ bundle add steam_api_clientWithout Bundler, install it with:
$ gem install steam_api_clientand load it with:
require "steam_api_client"SteamApiClient::Client.configure do |config|
config.api_token = ENV.fetch("STEAM_API_KEY") # https://steamcommunity.com/dev/apikey
end
client = SteamApiClient::Client.new
player = client.player_summaries.retrieve(steamids: [76561197960435530]).first
player.persona_name # => "Robin"
client.player_level.retrieve(steamid: player.steam_id) # => 32
client.player_owned_games.retrieve(steamid: player.steam_id) # => OwnedGames, or nil when private
client.app_details.retrieve(appid: 440, filters: ["basic"]).name # => "Team Fortress 2"
client.game_current_players.retrieve(appid: 440) # => 88231Results are immutable Data objects with snake_case fields (or Integers, or Arrays of them). HTTP errors raise SteamApiClient::Errors::* classes, e.g. HttpTooManyRequests with #retry_after.
See docs/USAGE.md for every endpoint and what it returns, configuration (timeouts, adapter, Faraday middleware, logging without leaking the key), errors and retries, and Steam's limits.
- Ruby >= 3.3
Run the following command to set up the gem using Bundler:
$ bin/setupLaunch an interactive Ruby session:
$ bin/consoleExecute all automated tests:
$ bin/rspecWe use standardrb for linting and code quality checks. To analyze the code, run:
$ bin/lintEach pull request with a user-visible change adds a line under ## [Unreleased] in CHANGELOG.md. Pull requests don't change the version.
To release the merged changes, open a release pull request:
$ git checkout -b release/0.10.0
$ bin/bump minor # or patch / major: bumps version.rb and Gemfile.lock, moves [Unreleased] under "## [0.10.0] - <today>"Commit, open the pull request, and merge it. Then publish from main:
$ bin/release # build and push the gem (asks for your RubyGems MFA code), then tag v<version> and push the tag
$ bin/release --dry-run # show what would happen without building, pushing or taggingbin/release checks out and pulls main first, and refuses to run with uncommitted changes or without a CHANGELOG entry. Steps that are already done are skipped, so running it again for a released version does nothing.
Bug reports, endpoint requests and pull requests are welcome on GitHub. Every change starts with an issue; see CONTRIBUTING.md for the setup, the checks and the CHANGELOG rules. Security problems go through SECURITY.md, not public issues.
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Code of Conduct.
This gem is available as open source under the terms of the MIT License.
Everyone interacting in the Steam project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the Code of Conduct.