/gwitch

A gem can get switch games' info (including price) from Nintendo official API.

Primary LanguageRubyMIT LicenseMIT

Gwitch

Gwitch can get switch games' info (including price) from Nintendo official API.

中文说明 | RubyGems

Prerequisites

  • ruby >= 2.3

Installation

gem install gwitch

Or you can install via Bundler if you are using Rails. Add this line to your application's Gemfile:

gem 'gwitch'

And then execute:

$ bundle

Basic Usage

Bash

Usage: gwitch [options]
    -g, --games                      Get all games (without price info)
    -p, --price alpha2,nsuid1,nsuid2 Get games' price (Max 50 nsuids)
    -c, --countries                  Get avaliable countries' alpha2 code
    -v, --version                    Print version and exit
    -h, --help                       Show help

The returned data will always be in json format.

Can be used with pipes and redirects.

eg.

gwitch -g >> games.json

Ruby

require 'gwitch'

Get all games.

games = Gwitch::Game.all

Get all avaliable countries.

countries = Gwitch::Country.all

Get country's info.

country = countries.first
country.alpha2     # => 'US'
country.region     # => 'Americas'
country.currency   # => 'USD'
country.avaliable? # => true

Query games' price (Max 50 games).

prices = Gwitch::Game.price('US', 'en', '70010000000141,70010000000142')

prices = Gwitch::Game.price('US', 'en', ['70010000000141', '70010000000142'])

prices = Gwitch::Game.price('US', 'en', [70010000000141, 70010000000142])

Build

git clone https://github.com/Dounx/gwitch
cd gwitch
gem build gwitch.gemspec
gem install --local gwitch-*.gem

Rake

List of available tasks

rake --tasks

License

Gwitch is an open-sourced software licensed under the MIT license.