Ruby Netflix API wrapper
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 27 commits ahead, 7 commits behind dholdren:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Netflix API for Ruby

Copyright © 2012 Dean Holdren

To install: gem install netflix

This gem uses Netflix's OAuth REST API, you first need to register an application with Netflix at

This will provide you with a “consumer key”, “consumer secret”, and “application name”

To use unauthenticated features (catalog search):

  • You can download the full XML catalog if you like. It's quite large and takes a while.

    1. Do this code

    client =
    catalog = client.catalog
    1. Wait.

To use authenticated features (i.e. queue management):

  • Set the consumer/developer config:

    Netflix::Client.consumer_key = <your consumer/developer key>
    Netflix::Client.consumer_secret = <your consumer/developer secret>
  • Do OAuth dance: (This is a one-time per user step, save the result somewhere.)

    1. Interactive (commandline/irb): This will open a web page to ask the user to authenticate, and provide a pin.

      access_token =
    2. or Web application (Rails/Sinatra/etc), define a URL that can handle the callback

      request_token, auth_url =
      session[:request_token] = request_token
      redirect_to auth_url

      Then in the handler for “my_callback_url” (i.e. a Rails controller action) retrieve the :oauth_verifier out of the request params

      oauth_verifier = params[:oauth_verifier]
      request_token = session[:request_token]
      access_token =, oauth_verifier)
  • After OAuth credentials are established:

    access_token = access_token.token
    access_secret = access_token.secret
    user_id = access_token.params["user_id"]

    (Record these, for example in a User table in a database)

    client =, access_token_secret)
    user = client.user(user_id)
    queue = user.available_disc_queue
    discs = queue.discs
    disc_one = discs[0]
    puts "#{disc_one.title} #{}"
    queue.remove(1) #queue is 1-based, so this is first disc


This work is based on: REST API documentation of Netflix (, with some help from twitter gem for OAuth ideas

Some extra work from the [Goodfilms]( team