🐲 Wrapper for hearthstoneapi.com
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
LICENSE.txt
README.md
Rakefile
hearthstone_api.gemspec

README.md

logo

HearthstoneApi

Gem Version

API Wrapper for hearthstoneapi.com

Installation

Add this line to your application's Gemfile:

gem 'hearthstone_api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install hearthstone_api

Create a .env file and add your API Key

$ touch .env

In the .env file:

HEARTHSTONE_API_KEY=xxxxxxxxxxxxxxxxxxxx

Endpoints

All endpoints available via hearthstoneapi.com

  1. All Cards
  2. Single Card
  3. Class Cards
  4. Types
  5. Sets
  6. Races
  7. Qualities
  8. Factions
  9. Search
  10. Card Backs
  11. Info

Examples:

All Cards

N.B. Cards come back organized by the set they belong to

HearthstoneApi::Cards.all(attack: 12)

=> {"Basic"=>[],
    "Classic"=>
      [{"cardId"=>"NEW1_030",
        "name"=>"Deathwing",
        "cardSet"=>"Classic",
        "type"=>"Minion",
        "rarity"=>"Legendary",
        "cost"=>10,
        "attack"=>12,
        "health"=>12,
        [...]

Single Card

This endpoint accepts name or card ID

HearthstoneApi::Cards.single("Ysera", locale: "jaJP")

=> [{"cardId"=>"EX1_572",
      "name"=>"イセラ",
      "cardSet"=>"Classic",
      "type"=>"Minion",
      "faction"=>"Neutral",
      "rarity"=>"Legendary",
      "cost"=>9,
      [...]

HearthstoneApi::Cards.single("EX1_572", locale: "jaJP")

=> [{"cardId"=>"EX1_572",
      "name"=>"イセラ",
      "cardSet"=>"Classic",
      "type"=>"Minion",
      "faction"=>"Neutral",
      "rarity"=>"Legendary",
      "cost"=>9,
      [...]

Class Cards

HearthstoneApi::Cards.classes("Paladin", cost: 2)

=> [{"cardId"=>"OG_311",
      "name"=>"A Light in the Darkness",
      "cardSet"=>"Whispers of the Old Gods",
      "type"=>"Spell",
      "rarity"=>"Common",
      "cost"=>2,
      "text"=>"<b>Discover</b> a minion.\nGive it +1/+1.",
      [...]

Types

HearthstoneApi::Cards.type("Weapon")

=> [{"cardId"=>"TB_SPT_BossWeapon",
      "name"=>"Armory",
      "cardSet"=>"Tavern Brawl",
      "type"=>"Weapon",
      "cost"=>1,
      "attack"=>0,
      "durability"=>1,
      [...]

Sets

HearthstoneApi::Cards.sets("Blackrock Mountain")

=> [{"cardId"=>"BRMA16_1",
      "name"=>"Atramedes",
      "cardSet"=>"Blackrock Mountain",
      "type"=>"Hero",
      "health"=>30,
      [...]

Races

Mrglglrglglglglglglgl!

HearthstoneApi::Cards.races("Murloc")

=> [{"cardId"=>"PRO_001at",
      "name"=>"Murloc",
      "cardSet"=>"Promotion",
      "type"=>"Minion",
      "cost"=>0,
      "attack"=>1,
      "health"=>1,
      "race"=>"Murloc",
      [...]

Qualities

HearthstoneApi::Cards.qualities("Legendary")

=> [{"cardId"=>"BRMA14_3",
      "name"=>"Arcanotron",
      "cardSet"=>"Blackrock Mountain",
      "type"=>"Minion",
      "rarity"=>"Legendary",
      [...]

Factions

HearthstoneApi::Cards.factions("Horde")

=> [{"cardId"=>"CS2_189",
      "name"=>"Elven Archer",
      "cardSet"=>"Basic",
      "type"=>"Minion",
      "faction"=>"Horde",
      "rarity"=>"Free",
      "cost"=>1,
      "attack"=>1,
      "health"=>1,
      [...]

Search

Returns cards by partial name

N.B. When searching by locale, the search term must be in that language

HearthstoneApi::Cards.search("Onyx")

=> [{"cardId"=>"BRMA17_3",
      "name"=>"Onyxia",
      "cardSet"=>"Blackrock Mountain",
      "type"=>"Hero",
      "health"=>15,
      [...]

HearthstoneApi::Cards.search("イセラ", locale: "jaJP")

=> [{"cardId"=>"LOEA16_15",
      "name"=>"イセラの涙",
      "cardSet"=>"The League of Explorers",
      "type"=>"Spell",
      "cost"=>0,
      "text"=>"このターンの間のみ、マナクリスタル\nを4つ獲得する。",

Card Backs

HearthstoneApi::Cardbacks.all

=> [{"cardBackId"=>"0",
      "name"=>"Classic",
      "description"=>"The only card back you’ll ever need.",
      "source"=>"startup",
      "sourceDescription"=>"Default",
      "enabled"=>true,
      "img"=>
        "http://wow.zamimg.com/images/hearthstone/backs/original/Card_Back_Default.png",
      "imgAnimated"=>
        "http://wow.zamimg.com/images/hearthstone/backs/animated/Card_Back_Default.gif",
      "sortCategory"=>"1",
      "sortOrder"=>"1",
      [...]

Info

HearthstoneApi::Info.all

=> {"patch"=>"5.0.0.12574",
      "classes"=>
        ["Druid",
          "Hunter",
          "Mage",
          "Paladin",
          "Priest",
          "Rogue",
          "Shaman",
          "Warlock",
          "Warrior",
          "Dream"],
      "sets"=>
        ["Basic",
          "Classic",
          "Credits",
          "Naxxramas",
          [...]

Contributing

  1. Fork it ( https://github.com/[my-github-username]/hearthstone_api/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Development

gem build hearthstone_api.gemspec
gem install ./hearthstone_api-1.0.2.gem