twenty3andme

Ruby API client and Rails engine for creating applications that integrate with data from the personal genetic testing service 23AndMe.

api.23andme.com/

Install

Bundler via Gemfile

gem 'twenty3andme'

Use with Rails

Use environment variables to configure:

CLIENT_ID=shdfkjhsdfkj23
CLIENT_SECRET=sadiuyf79238
REDIRECT_URI=http://localhost:5000/callback_listener/
AFTER_REDIRECT_URI=/
SCOPE=basic,rs3094315

Send user to authorize app with 23andme, A URL helper is provided to help with this (url_for_23andme_authorize):

link_to 'authorize', url_for_23andme_authorize

Then implement CallbackHandler#handle to use or store token and redirect user. Example:

module Twenty3AndMe
  class CallbackHandler
    def handle(token, refresh_token)
      User.create(:token => token, :refresh_token => refresh_token)
    end
  end
end

Now requests can be made with the stored token:

user = User.first
client = Twenty3AndMe::Client.new
client.token = user.token
client.genotype('rs3094315')

Use without Rails

First, Authorize and receive the code from 23andme: api.23andme.com/authorize/?redirect_uri=http://localhost:5000/receive_code/&response_type=code&client_id=a8a1f21d3417b70de786daea7e9ce2a8&scope=names basic haplogroups relatives genome

c = Twenty3AndMe::Client.new
c.request_token('client_id', 'client_secret', 'code_from_above', 'http://localhost:5000/receive_code/', ['ancestry', 'basic', 'rs4778241'])

Requests can now be made

c.user