RBattlenet

Code Climate

A Ruby gem that wraps Blizzard's Battle.net Community Platform API. Currently, RBattlenet only covers the World of Warcraft, Diablo 3 and StarCraft 2 APIs

Installation

Add this line to your application's Gemfile:

gem 'rbattlenet'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rbattlenet

Usage

Step 1. Setting your Battle.net API Key

Your private Battle.net API key must be present in order to get a valid Battle.net API response. Before any requests are made, your API key must be set like so:

api_key = "abcdefgh"

RBattlenet.authenticate(api_key: api_key)

Step 2. Setting your region and locale (Optional)

Your region and locale defaults to US and en_US respectively. However, these can be changed like so:

RBattlenet.set_region(region: "eu", locale: "en_GB")

Step 3. Call the API methods to request data

character = RBattlenet::Wow::Character.find(name: "milhause", realm: "saurfang")
#character["name"] will give you "Milhause"

Testing

API=<your_api> bundle exec rspec

Documentation

World of Warcraft

Starcraft 2

Diablo 3


World of Warcraft

Achievement

achievement = RBattlenet::Wow::Achievement.find(id: 2144)

Auction

RBattlenet::Wow::Auction.find(realm: "saurfang")

Battle Pet

Abilities

RBattlenet::Wow::Battlepet.find_abilities(id: 640)

Species

RBattlenet::Wow::Battlepet.find_species(species_id: 258)

Stats

RBattlenet::Wow::Battlepet.find_stats(species_id: 258,
  level: 25,
  breed_id: 5,
  quality_id: 4)

Challenge

Realm Leaderboard

RBattlenet::Wow::Challenge.find_realm(realm: "saurfang")

Region Leaderboard

RBattlenet::Wow::Challenge.find_region

Character

Profile

RBattlenet::Wow::Character.find(name: "milhause", realm: "saurfang")

Additional Fields

To see all possible fields visit: https://dev.battle.net/

RBattlenet::Wow::Character.find(name: "milhause",
  realm: "saurfang",
  fields: ["pet slots", "guild"])

Data Resources

Battlegroups

RBattlenet::Wow::DataResources.find_battlegroups

Character Achievements

RBattlenet::Wow::DataResources.find_character_achievements

Character Classes

RBattlenet::Wow::DataResources.find_character_classes

Character Races

RBattlenet::Wow::DataResources.find_character_races

Guild Achievements

RBattlenet::Wow::DataResources.find_guild_achievements

Guild Perks

RBattlenet::Wow::DataResources.find_guild_perks

Guild Rewards

RBattlenet::Wow::DataResources.find_guild_rewards

Item Classes

RBattlenet::Wow::DataResources.find_item_classes

Pet Types

RBattlenet::Wow::DataResources.find_pet_types

Talents

RBattlenet::Wow::DataResources.find_talents

Item

Item

RBattlenet::Wow::Item.find(id: 18803);

Item Set

RBattlenet::Wow::Item.find_set(id: 1060)

Guild

Profile

RBattlenet::Wow::Guild.find(name: "razors edge", realm:"saurfang")

Additional data

RBattlenet::Wow::Guild.find(name: "razors edge",
  realm: "saurfang",
  fields: ["members", "news"])

PVP

Leaderboards

RBattlenet::Wow::Pvp.find_bracket(bracket: "2v2")

Quest

RBattlenet::Wow::Quest.find(id: 13146)

Realm Status

RBattlenet::Wow::Realm.find

Recipe

RBattlenet::Wow::Recipe.find(id: 33994)

Spell

RBattlenet::Wow::Spell.find(id: 8056)

Starcraft 2

Profile

RBattlenet::Sc2::Profile.find(id: 1234567, region: 1, name: 'name')

Ladders

RBattlenet::Sc2::Profile.find_ladders(id: 1234567, region: 1, name: 'name')

Match history

RBattlenet::Sc2::Profile.find_match_history(id: 2137104, region: 1, name: 'skt')

Ladder

RBattlenet::Sc2::Ladder.find(id: 2200)

Data Resources

Achievements

RBattlenet::Sc2::DataResources.find_achievements

Rewards

RBattlenet::Sc2::DataResources.find_rewards

Diablo 3

Data Resources

Artisan

RBattlenet::D3::DataResources.find_artisan(artisan: 'blacksmith')

Follower

RBattlenet::D3::DataResources.find_follower(follower: 'templar')

Item

data = "CrABCL-oudQGEgcIBBWZWjYNHWU61OAdyg3pEx07J28kHevi5AUd8dNq1TCLAjj_AkAAUBJYBGD_AmorCgwIABDX3bKmiICA4DESGwi5u5abChIHCAQVIpaumDCPAjgAQAFYBJABAGorCgwIABCl3rKmiICA4DESGwiR9M-gAhIHCAQVIpaumDCLAjgAQAFYBJABAIABRqUBOydvJK0Bj5DKULUBAXBvArgB9aCdsg7AAQEYsuqy0wFQAFgC"

RBattlenet::D3::DataResources.find_item(data: data)

Profile

Career

RBattlenet::D3::Profile.find_career(battletag: "username")

Hero

RBattlenet::D3::.find_hero(battletag: "username", id: 1234567)

Contributing

  1. Fork it ( https://github.com/[my-github-username]/rbattlenet/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