Project

rawg_rb

0.0
No release in over 3 years
Low commit activity in last 3 years
A Ruby client for RAWG.io API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 5.0, >= 5.0.2
~> 0.12.2
~> 10.0
~> 3.8
~> 3.6

Runtime

~> 0.15.4
 Project Readme

💎 RAWG.rb

Gem Version Build Status codecov Inline docs

This is a Ruby client for RAWG API.

RAWG.io is the largest video game database and game discovery service. See rawg.io/apidocs for rules and additional information about the API.

Installation

Add this line to your Gemfile:

gem 'rawg_rb'

Or install manually:

$ gem install rawg_rb

Usage

# You should provide a user agent to identify your app.
rawg = RAWG::Client.new(user_agent: 'MyAwesomeApp/1.0')

# Fetch a game by slug or id
rawg.game('fallout')
rawg.game(132026)

minecraft = rawg.game('minecraft') # => <RAWG::Game>
minecraft.id           # => 22509
minecraft.slug         # => "minecraft"
minecraft.name         # => "Minecraft"
minecraft.description  # => "<p>One of the most popular games of the 2010s...
minecraft.website      # => "https://minecraft.net"
minecraft.rating       # => 4.32

# Find similar games
games_like_minecraft = minecraft.suggested     # => <RAWG::Paginator>

# Paginator is Enumerable.
# If the result contains multiple pages, additional pages will be requested if needed.
games_like_minecraft.first(2).map(&:name)  # => ['Project Explore', 'Planet Nomads']

# Search games
rawg.games(search: 'gta')                      # => <RAWG::Paginator>
rawg.games(search: 'zombie', genres: 'racing') # => <RAWG::Paginator>

Simple Requests

These methods return a hash containing API response as it is.

rawg.all_games(genres: 'indie')
rawg.search_games('zombie', genres: 'racing')
rawg.search_games(genres: 'indie')
rawg.game_info(132026)
rawg.game_suggest('minecraft')

Contributing

Feel free to submit new issues at github.com/ivanlobko/rawg.rb/issues.

License

The gem is available as open source under the terms of the MIT License.