GW2.rb is a Ruby gem that wraps the GW2 API in a Ruby-flavored way. It is currently under development and is not ready for production yet.
Please note this is not hosted on RubyGems yet! This is merely placeholder information! Add this line to your application's Gemfile:
gem 'gw2rb'
And then execute:
$ bundle
Or install it yourself as:
$ gem install gw2rb
To initialize a client, you can call GW2.client
with or without an API key:
authenticated_client = GW2.client("BEST-API-KEY-EVER")
client = GW2.client
An API key is necessary to access many of the GW2 API endpoints and is highly recommended.
Methods return arrays or hashes with JSON-formatted key/value pairs.
The following methods can all be called without an API key.
Returns an array of all achievement IDs.
Returns a hash of information for the achievement IDs specified with the keys: :id
, :name
, :description
, :requirement
, :locked_text
, :type
, :flags
, and :tiers
.
The required id
parameter takes:
- an Integer =>
achievement_info(1)
- a String of ID number(s) =>
achievement_info("1,2,3")
orachievement_info("1")
- an Array of ID numbers =>
achievement_info([1,2,3])
orachievement_info(["1", "2", "3"])
achievement = @client.achievement_info(1)
achievement[:name]
# returns "Centaur Slayer"
Returns an array of all achievement categories when not passed an ID.
When an ID is provided, returns a hash of information for the achievement category ID with the keys: :id
, :name
, :description
, :order
, :icon
, and :achievements
.
The optional id
parameter takes:
- an Integer =>
achievement_categories(1)
- a String of ID number(s) =>
achievement_categories("1,2,3")
orachievement_categories("1")
- an Array of ID numbers =>
achievement_categories([1,2,3])
orachievement_categories(["1", "2", "3"])
category = @client.achievement_categories(1)
category[:name]
# Returns "Slayer"
Returns an array of all achievement groups when not passed an ID.
When an ID is passed, returns a hash of information for the achievement category ID with the keys: :id
, :name
, :description
, :order
, and :categories
.
The optional id
parameter takes:
- a String of ID(s) =>
achievement_groups('"45410F60-AB66-4146-A0F7-CE99250C4CB0", "A4ED8379-5B6B-4ECC-B6E1-70C350C902D2"')
orachievement_groups("A4ED8379-5B6B-4ECC-B6E1-70C350C902D2")
- an Array of IDs =>
achievement_groups(["45410F60-AB66-4146-A0F7-CE99250C4CB0", "A4ED8379-5B6B-4ECC-B6E1-70C350C902D2"])
group = @client.achievement_groups("56A82BB9-6B07-4AB0-89EE-E4A6D68F5C47")
group[:name]
# Returns "General"
Returns a hash of information for today's daily achievements with the keys: :pve
, :pvp
, :wvw
, and :special
.
dailies = @client.dailies
dailies[:pve]
# Returns an array of hashes where each item (hash) in the array represents a daily pve achievement
Returns a hash of information for tomorrow's daily achievements with the keys: :pve
, :pvp
, :wvw
, and :special
.
dailies_tomorrow = @client.dailies_tomorrow
dailies_tomorrow[:wvw]
# Returns an array of hashes where each item (hash) in the array represents a daily wvw achievement for tomorrow.
Returns an array of all legend IDs.
Returns a hash of information for specified profession(s) with the keys: :id
, :swap
, :heal
, :elite
, and :utilities
.
The optional id
parameter takes:
- a String of ID(s) =>
legend_info("Legend2, Legend4")
orlegend_info("Legend2")
- an Array of IDs =>
legend_info(["Legend2", "Legend4"])
legendary_assassin = @client.legend_info("Legend2")
legendary_assassin[:elite]
# Returns the skill ID (28406) to be resolved using #skill_info
Returns an array of all profession IDs (which are strings).
Returns a hash of information for specified profession(s) with the keys: :id
, :name
, :icon
, :icon_big
, :specializations
, :weapons
, and :training
.
The required id
parameter takes:
- a String of ID(s)=>
profession_info("Mesmer, Thief")
orprofession_info("Mesmer")
- an Array of IDs =>
profession_info(["Mesmer", "Thief"])
mesmer_info = @client.profession_info("Mesmer")
mesmer_info[:weapons][:Focus][:skills]
# Returns an array of hashes where each item (hash) in the array represents a weapon skill
Returns an array of all skill IDs.
Returns a hash of information for specified skill(s) with the keys: :id
, :name
, :icon
, :chat_link
, :type
, :weapon_type
, :professions
, :slot
, as well as a large number of optional keys. For the complete list, see the official API documentation for skills endpoint.
The required id
parameter takes:
- an Integer =>
skill_info(5490)
- a String of ID number(s) =>
skill_info("5490,5491,5492")
orskill_info("5490")
- an Array of ID numbers =>
skill_info([5490,5491,5492])
orskill_info(["5490", "5491", "5492"])
warrior_skill_info = @client.skill_info(14375)
warrior_skill_info[:name]
# Returns a string with the name of the skill e.g. "Arcing Slice"
Returns an array of all specialization IDs.
Returns a hash of information for specified specialization(s) with the keys: :id
, :name
, :profession
, :elite
, :icon
, :background
, :minor_traits
, and :major_traits
.
The required id
parameter takes:
- an Integer =>
specialization_info(1)
- a String of ID number(s) =>
specialization_info("1,2,3")
orspecialization_info("1")
- an Array of ID numbers =>
specialization_info([1,2,3])
orspecialization_info(["1", "2", "3"])
dueling_info = @client.specialization_info(1)
dueling_info[:minor_traits]
# Returns an array of integers where each item (integer) in the array represents a trait ID which can be resolved using #trait_info
Returns an array of all skill IDs.
Returns a hash of information for specified skill(s) with the keys: :id
, :name
, :icon
, :description
:specialization
, :tier
, :slot
, as well as optional :facts
, :traited_facts
, and :skills
.
The required id
parameter takes:
- an Integer =>
trait_info(2058)
- a String of ID number(s) =>
trait_info("2056,2057,2058")
ortrait_info("2058")
- an Array of ID numbers =>
trait_info([2056,2057,2058])
ortrait_info(["2056", "2057", "2058"])
lingering_light = @client.trait_info(2058)
lingering_light[:name]
# Returns a string with the name of the trait e.g. "Lingering Light"
TODO: All other standard methods.
TODO: These 😉
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/sinthetix/gw2rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.