A Ruby gem that wraps Blizzard's Battle.net Community Platform API. Currently, RBattlenet only covers the Hearthstone, World of Warcraft, Diablo 3 and StarCraft 2 APIs
Add this line to your application's Gemfile:
gem 'rbattlenet', github: 'austra/rbattlenet'
And then execute:
$ bundle
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:
client_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client_secret = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
RBattlenet.authenticate(client_id: client_id, client_secret: client_secret)
Your region and locale defaults to US and en_US respectively. However, these can be changed like so:
RBattlenet.set_region(region: "us", locale: "en_US")
character = RBattlenet::Wow::DataResources.find_character_classes
{"classes"=>
[{"id"=>1, "mask"=>1, "powerType"=>"rage", "name"=>"Warrior"},
{"id"=>2, "mask"=>2, "powerType"=>"mana", "name"=>"Paladin"},
{"id"=>3, "mask"=>4, "powerType"=>"focus", "name"=>"Hunter"},
{"id"=>4, "mask"=>8, "powerType"=>"energy", "name"=>"Rogue"},
{"id"=>5, "mask"=>16, "powerType"=>"mana", "name"=>"Priest"},
{"id"=>6, "mask"=>32, "powerType"=>"runic-power", "name"=>"Death Knight"},
{"id"=>7, "mask"=>64, "powerType"=>"mana", "name"=>"Shaman"},
{"id"=>8, "mask"=>128, "powerType"=>"mana", "name"=>"Mage"},
{"id"=>9, "mask"=>256, "powerType"=>"mana", "name"=>"Warlock"},
{"id"=>10, "mask"=>512, "powerType"=>"energy", "name"=>"Monk"},
{"id"=>11, "mask"=>1024, "powerType"=>"mana", "name"=>"Druid"},
{"id"=>12, "mask"=>2048, "powerType"=>"fury", "name"=>"Demon Hunter"}]}
CLIENT_ID=<your_id> CLIENT_SECRET=<your_secret> bundle exec rspec
- Refactor specs to use Mocks/Stubs instead of making real API calls
- Add specs that make real API calls that only run when a flag if provided
- Add a CHANGELOG
- Achievement
- Auction
- Battle Pet
- Challenge
- Character
- Data Resources
- Guild
- Item
- PVP
- Quest
- Realm Status
- Recipe
- Spell
https://develop.battle.net/documentation/api-reference/hearthstone-game-data-api
args = {
set: 'rise-of-shadows',
class: 'mage',
mana_cost: 10,
attack: 4,
health: 10,
collectible: 1,
rarity: 'legendary',
type: 'minion',
minion_type: 'dragon',
keyword: 'battlecry',
text_filter: 'kalecgos',
page: 1,
page_size: 5,
sort: 'name',
order: 'desc'
}
cards = RBattlenet::Hearthstone::Card.find_cards(args)
card = RBattlenet::Hearthstone::Card.find_card(id_or_slug: '52119-arch-villain-rafaam')
deck = RBattlenet::Hearthstone::Deck.find_deck(deckcode: 'AAECAQcG+wyd8AKS+AKggAOblAPanQMMS6IE/web8wLR9QKD+wKe+wKz/AL1gAOXlAOalAOSnwMA')
metadata = RBattlenet::Hearthstone::Metadata.all_metadata()
# valid types: sets, setGroups, types, rarities, classes, minionTypes, and keywords.
metadata = RBattlenet::Hearthstone::Metadata.find_metadata(type: 'sets')
achievement = RBattlenet::Wow::Achievement.find(id: 2144)
RBattlenet::Wow::Auction.find(realm: "saurfang")
RBattlenet::Wow::Battlepet.find_abilities(id: 640)
RBattlenet::Wow::Battlepet.find_species(species_id: 258)
RBattlenet::Wow::Battlepet.find_stats(species_id: 258,
level: 25,
breed_id: 5,
quality_id: 4)
RBattlenet::Wow::Challenge.find_realm(realm: "saurfang")
RBattlenet::Wow::Challenge.find_region
RBattlenet::Wow::Character.find(name: "milhause", realm: "saurfang")
To see all possible fields visit: https://dev.battle.net/
RBattlenet::Wow::Character.find(name: "milhause",
realm: "saurfang",
fields: ["pet slots", "guild"])
RBattlenet::Wow::DataResources.find_battlegroups
RBattlenet::Wow::DataResources.find_character_achievements
RBattlenet::Wow::DataResources.find_character_classes
RBattlenet::Wow::DataResources.find_character_races
RBattlenet::Wow::DataResources.find_guild_achievements
RBattlenet::Wow::DataResources.find_guild_perks
RBattlenet::Wow::DataResources.find_guild_rewards
RBattlenet::Wow::DataResources.find_item_classes
RBattlenet::Wow::DataResources.find_pet_types
RBattlenet::Wow::DataResources.find_talents
RBattlenet::Wow::Item.find(id: 18803);
RBattlenet::Wow::Item.find_set(id: 1060)
RBattlenet::Wow::Guild.find(name: "razors edge", realm:"saurfang")
RBattlenet::Wow::Guild.find(name: "razors edge",
realm: "saurfang",
fields: ["members", "news"])
RBattlenet::Wow::Pvp.find_bracket(bracket: "2v2")
RBattlenet::Wow::Quest.find(id: 13146)
RBattlenet::Wow::Realm.find
RBattlenet::Wow::Recipe.find(id: 33994)
RBattlenet::Wow::Spell.find(id: 8056)
Not working: RBattlenet::Sc2::Profile.find(id: 1234567, region: 1, name: 'name')
RBattlenet::Sc2::Profile.find_ladders(id: 1234567, region: 1, name: 'name')
RBattlenet::Sc2::Profile.find_match_history(id: 2137104, region: 1, realm: 1)
RBattlenet::Sc2::Ladder.find(id: 2200)
RBattlenet::Sc2::DataResources.find_achievements
RBattlenet::Sc2::DataResources.find_rewards
RBattlenet::D3::DataResources.find_artisan(artisan: 'blacksmith')
RBattlenet::D3::DataResources.find_follower(follower: 'templar')
data = "CrABCL-oudQGEgcIBBWZWjYNHWU61OAdyg3pEx07J28kHevi5AUd8dNq1TCLAjj_AkAAUBJYBGD_AmorCgwIABDX3bKmiICA4DESGwi5u5abChIHCAQVIpaumDCPAjgAQAFYBJABAGorCgwIABCl3rKmiICA4DESGwiR9M-gAhIHCAQVIpaumDCLAjgAQAFYBJABAIABRqUBOydvJK0Bj5DKULUBAXBvArgB9aCdsg7AAQEYsuqy0wFQAFgC"
RBattlenet::D3::DataResources.find_item(data: data)
RBattlenet::D3::Profile.find_career(battletag: "username")
RBattlenet::D3::.find_hero(battletag: "username", id: 1234567)
- Fork it ( https://github.com/[my-github-username]/rbattlenet/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request