This short example will show you how to authorize your own account against the API and make requests. Note that we aren't following a full OAuth flow here because as a developer you already have access to your own access token and secret.

# Use the OAuth gem
require 'rubygems'
require 'oauth'

# Your key/secrets for authentication
CONSUMER_KEY        = '0cc175b9c0f1b6a831c399e269772661'
CONSUMER_SECRET     = 'ff2513194e75315625628304c9eb66e8'
ACCESS_TOKEN        = '150a96573adf12b21dab621e85497e6e'
ACCESS_TOKEN_SECRET = '5c7b57d450a71d378a5eda991f809e56'

# Set up an OAuth Consumer
@consumer = CONSUMER_KEY, CONSUMER_SECRET, { :site => '' }

# Manually update the access token/secret.  Typically this would be done through an OAuth callback when 
# authenticating other users.

# Make a request to the API endpoint and display the response
puts @access_token.get('/v1/accounts.json', {'Accept' => 'application/json'})

Any mention of actual symbols are to be used for coding purposes only and do not imply a recommendation or solicitation to buy or sell a particular security or to engage in any particular investment strategy.

At the time of publication and in the preceding month, TradeKing did not have ownership greater than 1% in any stocks mentioned here and does not have any other actual, material conflict of interest known at the time of publication. TradeKing did not receive compensation from a public offering or from investment banking services related to any companies mentioned here within the past 12 months, or expects to receive any in the next 3 months. TradeKing did not engage in market making in the securities mentioned here.