D3api
This gem is a ruby wrapper to Blizzard's Diablo 3 api.
Installation
Add this line to your application's Gemfile:
gem 'd3api'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install d3api
Usage
All objects are tied to regions. Every api call will require a region to be set. The available list of regions are:
- :us
- :eu
- :kr
- :tw
- :ch
Career
To get a user's Diablo 3 career, you need to know 3 things:
- BattleTag Name
- BattleTag Code
- Region
Then it's ruby time.
@career = D3api::Career.new(:us, 'yojymbu', '1249')
This will return a Career object with json values. I tried my best to implement nice methods to get through the values such as:
@career.heroes #=> returns an array of heroes
@career.last_hero_played #=> returns the id of last hero played
@careerlast_updated.
@career.artisans #=> returns a hash of your arisan information
@career.monster_kills #=> returns an integer
There is a ton of data gleaned from the career object. Just look at Blizzard's Diablo 3 api docs for more information. You can also look through the respc tests to get a better idea of what the methods are to utilize.
Hero
To get a user's Diablo 3 hero, you need to know 4 things:
- BattleTag Name
- BattleTag Code
- Region
- Hero ID
@hero = D3api::Hero.new :us, 'yojymbu', '1249', '30255685' #=>
returns hero object
@hero.name #=> Returns name of character
@hero.hero_class #=> Returns class of character
@hero.skills #=> returns an array of hashes for active and passive
skills
@hero.items #=> returns an array of hashes
Item
To get an item from Diablo 3, you need 2 things:
- Region
- Item String
@item = D3api::Item.new :us,
'COGHsoAIEgcIBBXIGEoRHYQRdRUdnWyzFB2qXu51MA04kwNAAFAKYJMD' #=> returns
an item object
@item.name #=> Exsanguinating Chopsword of Assault
@item.icon #=> mightyweapon1h_202
And many more. Please refer to Blizzard's Diablo 3 documentation for more information.
Follower / Artisan Information
You need 2 things:
- Region
- Follower or Artisan type
@follower = D3pi::Follower.new :us, 'scoundrel'
@artisan = D3api::Artisan.new :us, 'blacksmith'
That's It!
If you have any comments questions or concerns, please let me know.
ToDos
- Implement Authentication per Blizzards protocol (allow 10,000 unsigned requests or 50,000 signed requests).
Contributing
- Fork it
- 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 new Pull Request