---
layout: default
navsection: sdk
navmenu: Ruby
title: "Ruby SDK"
...
The Ruby SDK provides a generic set of wrappers so you can make API calls easily.
h3. Installation
If you are logged in to an Arvados VM, the Ruby SDK should be installed.
To use it elsewhere, you can either install the @arvados@ gem via RubyGems or build and install the package using the arvados source tree.
h4. Prerequisites: Ruby >= 2.0.0
You can use "RVM":http://rvm.io/rvm/install to install and manage Ruby versions.
h4. Option 1: install with RubyGems
$ sudo gem install arvados
h4. Option 2: build and install from source
$ git clone https://github.com/curoverse/arvados.git
$ cd arvados/sdk/ruby
$ gem build arvados.gemspec
$ sudo gem install arvados-*.gem
h4. Test installation
If the SDK is installed, @ruby -r arvados -e 'puts "OK!"'@ should produce no errors.
If your @ARVADOS_API_HOST@ and @ARVADOS_API_TOKEN@ environment variables are set up correctly (see "api-tokens":{{site.baseurl}}/user/reference/api-tokens.html for details), the following test script should work:
$ ruby -r arvados <<'EOF'
arv = Arvados.new api_version: 'v1'
my_full_name = arv.user.current[:full_name]
puts "arvados.v1.users.current.full_name = '#{my_full_name}'"
EOF
arvados.v1.users.current.full_name = 'Your Name'
h3. Examples
Import the module (we skipped this step above by using "ruby -r arvados"):
require 'arvados'
Set up an API client user agent:
arv = Arvados.new(apiVersion: 'v1')
Get the User object for the current user:
current_user = arv.user.current
Get the UUID of an object that was retrieved using the SDK:
current_user_uuid = current_user[:uuid]
Retrieve an object by ID:
some_user = arv.user.get(uuid: current_user_uuid)
Create an object:
new_link = arv.link.create(link: {link_class: 'test', name: 'test'})
Update an object:
updated_link = arv.link.update(uuid: new_link[:uuid],
link: {properties: {foo: 'bar'}})
Delete an object:
arv.link.delete(uuid: new_link[:uuid])
Get a list of objects:
repos = arv.repository.list
first_repo = repos[:items][0]
puts "UUID of first repo returned is #{first_repo[:uuid]}"
UUID of first repo returned is qr1hi-s0uqq-b1bnybpx3u5temz
The SDK retrieves the list of API methods from the server at run time. Therefore, the set of available methods is determined by the server version rather than the SDK version.