A Ruby library for XIVAPI.
Add this line to your application's Gemfile:
gem 'xivapi', git: 'https://github.com/xivapi/xivapi-ruby.git', tag: 'v0.3.3'
And then run:
$ bundle install
Full documentation for this library can be found here. For basic usage information, please see below.
Start by initializing a client. You can obtain an API key by signing in to XIVAPI here. The key is available under the Dev Account page after signing in.
require 'xivapi' # Basic configuration client = XIVAPI::Client.new(api_key: 'abc123') # Advanced configuration client = XIVAPI::Client.new(api_key: 'abc123', language: 'fr')
Now that you have a client, you can use it to contact the API. Examples have been provided below for the various endpoints. For the full list of endpoints and their parameters, please reference the request documentation.
The data returned from the API is automatically converted into OpenStruct objects with snake_cased keys. If the request returns multiple results (e.g. character search), it will be provided to you in the form of an
XIVAPI::Paginator object. The paginator is Enumerable, allowing you to access the data with methods like
See the examples below to get a better idea of how to access the data.
>> achievements = client.search(indexes: 'achievement', string: 'tankless') => ... >> achievements.map(&:name) => ["A Tankless Job II (Dark Knight)", "A Tankless Job I (Paladin)", "A Tankless Job I (Warrior)", "A Tankless Job II (Warrior)", "A Tankless Job I (Dark Knight)", "A Tankless Job II (Paladin)"] >> achievements.first.points => 10
>> client.content => ["Achievement", "AchievementCategory", "AchievementKind", ...] >> achievement = client.content(name: 'Achievement', limit: 1).first => ... >> achievement.name => "To Crush Your Enemies I" >> achievements = client.content(name: 'Achievement', ids: 4..5) => ... >> achievements.map(&:name) => ["To Crush Your Enemies IV", "To Crush Your Enemies V"]
>> client.servers => ["Adamantoise", "Aegis", "Alexander", ...]
>> characters = client.character_search(name: 'raelys skyborn', server: 'behemoth') => ... >> id = characters.first.id => 7660136 >> character = client.character(id: id, all_data: true) => ... >> character.character.name => "Raelys Skyborn" >> character.achievements.list.last.id => 692
>> fcs = client.free_company_search(name: 'lodestone', server: 'behemoth') => ... >> id = fcs.first.id => "9234349560946590421" >> fc = client.free_company(id: id, members: true) => ... >> fc.free_company.name => "Lodestone" >> fc.free_company_members.first.name => "Raelys Skyborn"
>> linkshells = client.linkshell_search(name: 'thunderbirds', server: 'behemoth') => ... >> id = linkshells.first.id => "21955048183495181" >> linkshell = client.linkshell(id: id).linkshell => ... >> linkshell.name => "Thunderbirds"
>> teams = client.pvp_team_search(name: 'kill', server: 'chaos') => ... >> team = client.pvp_team(id: teams.first.id).pvp_team => ... >> team.name => "!Kill_For_A_Friend!"
>> patch = client.patch_list.last => ... >> patch.name => "Patch 4.4: Prelude In Violet" >> Time.at(patch.release_date.to_i) => 2018-09-18 10:00:00 +0000
After checking out the repo, run
bin/setup to install dependencies. 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/xivapi/xivapi-ruby.
The gem is available as open source under the terms of the MIT License.