Reve

From EVEDev

Jump to: navigation, search
Image:Api.pngAPI Resources - Category Home - API Libraries - API Usage Examples - API Method Reference
Reve
Maintainer: Lisa Seelye (eve: Raquel Smith)
Stable release: rev42
Development release: SVN trunk
OS: Platform independant
License: Custom
Website: http://tinyurl.com/26e4jw


Reve is a free (Not for real life currency usage; ISK is fine) open source Ruby library wrapper for the Eve-Online API. Reve is available at http://www.crudvision.com/reve-ruby-eve-online-api-library/. Documentation is at http://docs.crudvision.com/reve and subversion at http://svn.crudvision.com/reve

Contents

[edit] Installation

To install Reve one must already have Ruby and Rubygems installed. Reve (as of revision 8) has one external dependency Hpricot. To install Reve and its dependency issue gem install reve from your command line.

[edit] Usage

Using the API is relatively easy. The library parses the data returned from CCP's API and wraps it all in classes. Make sure you have a userID and apiKey CCP's website for more advanced uses.

[edit] Examples

The simplest case to get at the API is to not pass a character's userID or apiKey.

#!/usr/bin/ruby
require 'reve'

api = Reve::API.new

[edit] Fetching all of the alliances

Let's now do something interesting with the api.

#!/usr/bin/ruby
require 'reve'

api = Reve::API.new
alliances = api.alliances
alliances.each do |alliance|
  puts "Found an alliance and its name is '#{alliance.name}' (but you probably call it #{alliance.short_name})."
end

That snippet will print up the screen:

Found an alliance and its name is 'GoonSwarm' (but you probably call it OHGOD).
Found an alliance and its name is 'FREGE Alliance' (but you probably call it FREGE).
Found an alliance and its name is 'Band of Brothers' (but you probably call it BOB).
Found an alliance and its name is 'Interstellar Alcohol Conglomerate' (but you probably call it IAC).

[edit] Getting your character sheet

First. the way we call the Reve::API.new constructor changes slightly to include our userID and secret apiKey.

#!/usr/bin/ruby
require 'reve'

api = Reve::API.new('your userID','your apiKey')
sheet = api.character_sheet(your_character_id)

puts "My name is #{sheet.name}, I belong to the #{sheet.corporation_name} corp and I have #{sheet.balance} ISK"

puts "My skills are thus:"
for skill in sheet.skills
  puts "typeID #{skill.id} is at level #{skill.level}."
end

Its output looks something like this:

My name is Raquel Smith, I belong to the Freedom-Technologies corp and I have 578376885.75 ISK

My skills are thus:
typeID 11584 is at level 1
typeID 3363 is at level 1
typeID 12487 is at level 2
...

NOTE: Due to a limitation in the API itself it is not possible to easily get the name of the skill with the character_sheet call.

[edit] Testing

As of revision 11 Reve comes with a test suite to ensure that everything is in working order. Get ahold of the source (subversion or the package above) and cd test and ruby reve_test.rb. The test suite will run and hopefully report everything is all okay.

It is important to note that the Reve test suite does not make a call to the API, rather, it wants to test that the Reve can do the right thing when given XML. Reve relies on the well-tested net/http from Ruby and the well-tested Hpricot from why the lucky stiff and tests itself and not those already tested things.

[edit] Usage Discussion

Reve was created for the Eve Online community and to do some Ruby evangelising. It is therefor free for use when any transaction that occurs happens in-game and for in-game ISK. Reve isn't licensed for usage where real-life currency transactions will occur. Post a comment to the reve library page if you wish to use Reve in that case, we'll come to an agreement.

[edit] Reve as a Rails Plugin

As of revision 50 or thereabouts, Reve will run as a Ruby on Rails plugin without modification. However, the preferred (and supported) use case is when installed as a gem.

[edit] Caching

Recache is a caching layer for Rails projects using Reve which performs transparent caching on Reve methods. It uses ActiveRecord to store cache data in the database.

Reve can also perform basic file-based caching with some modifications and should work with properly-designed proxy caches.

Retrieved from "http://wiki.eve-id.net/Reve"
Personal tools