Created: 2011-07-18 17:50
Updated: 2013-10-10 19:59
License: other

This gem implements Ruby bindings for the Howcast API.

From Howcast's About Us page:

Howcast empowers people with engaging, useful how-to information wherever, whenever they need to know how.

Known for high-quality content, Howcast streams tens of millions of videos every month across its multi-platform distribution network. Approaching two million downloads across iPhone, iPad, Android, and BlackBerry phones, Howcast is the #1 mobile app for instructional content -- wherever you are.


gem install howkast


Most of the service requests require an API key. You can either set this when you create an instance of Howkast::API:

howcast = :api_key => 'YOUR-API-KEY'

Or create a configuration that file and set it by invoking the Howkast::configure method:

# create the configuration file
cat > ~/.howkast <<EOF
:api_key: YOUR-API-KEY

# now use it
require 'rubygems'
require 'yaml'
require 'howkast'

Howkast::configure YAML.load'~/.howkast')
howcast =


require 'rubygems'
require 'yaml'
  require 'howkast'
rescue LoadError
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
  require 'howkast'

# configure
Howkast::configure YAML.load'.howkast')

# create instance
howcast =

# alternative instantiation
# howcast = :api_key => 'YOUR-HOWCAST-API-KEY'

# search for jujitsu how-to videos
search = :query => 'jujitsu'

# get detail for the first video listed in the search
video_id =
video    = :id => video_id
puts video.title
puts video.embed

# find out what other videos where uploaded by the same user
username = video.username
user     = howcast.user :id => username, :resource => :videos
puts user.title
user.videos.each do |video|
  puts "- #{}\t#{video.title}"

# list user's favorite videos
user = howcast.user :id => username, :resource => :favorites
puts user.title
user.videos.each do |video|
  puts "- #{}\t#{video.title}\t#{video.description}"

# list user's playlists
user = howcast.user :id => username, :resource => :playlists
puts user.title
user.playlists.each do |video|
  puts "- #{}\t#{video.title}"

# list available categories
categories = howcast.categories
categories.each do |category|
  puts "#{}\t#{}"

# get details about a category
category = howcast.category :id =>
category.subcategories.each do |category|
  puts "- #{}\t#{}"

# list the videos in a playlist
playlist = howcast.playlist :id => '4261'
puts playlist.title
puts playlist.description
playlist.videos.each do |video|
  puts "- #{}\t#{video.title}"


To identify what services are supported, you can invoke the services class method from the Howkast::API class:  # => [:video, :videos, :search, :user, :playlist, :category, :categories]

At the time of this writing, this gem implements all of the services listed in the Howcast API Documentation

The current implementation is that each service expects a Hash that names the parameters required to fulfill the request. The acceptable parameters (with a minor adjustments to make the parameter names consistent) closely match the documented service signatures.

Here are some examples to illustrate the service calls. Notice that the format parameter does not need to be specified and that the api_key only needs to be set at configuration or when the Howkast::API object is created:

Get Video

# GET<video_id>.<format>?api_key=<api_key> :id => 6570

List Videos

# GET<sort>/<filter>/<category>.<format>?api_key=<api_key>
howcast.videos :sort => :top_rated, :filter => :howcast_studios, :page => 5

Search Videos

# GET<format>?q=<query>&view=video&api_key=<api_key> :query => 'jujitsu'

List Top-Level Categories

# GET<format>?api_key=<api_key>    

Anyway, you get the idea.

Read the Howcast API Documentation for details.


The return value of a service request is an instance of Howkast::Model - the actual type returned depends on the service invoked.

The rule to determine the type of the response is:

  1. The name of the service in singular form dictates the name of the model (eg: video returns Howkast::Model::Video)
  2. If the service name is in plural form, then an Array of the expected model is returned.

The Howkast::Model instance returned will have the appropriate attributes as described in the Howcast API Documentation

You can examine the list of attributes by invoking the #instance_attributes method of the returned model:

video = :id => 6570
video.class                # => Howkast::Model::Video
video.instance_attributes  # => [:id, :category_id, :category_hierarchy, :easy_steps, :badges, :created_at, :filename, :tags, :title, :description, :permalink, :edit_url, :state, :duration, :width, :height, :embed, :rating, :username, :thumbnail_url, :views, :content_rating, :overlay, :ingredients, :markers, :related_videos, :comments]

And of course examine each attribute as needed:

video.category_hierarchy   # => Array of Howkast::Model::Category
video.title                # => "How To Drive a Stick Shift" 
video.related_videos       # => Array of Howkast::Model::Video
video.markers              # => Array of Howkast::Model::Marker
video.markers.first.type   # => Step


If a service request fails then a Howkast::Error::RequestError error type is raised. The actual type raised depends on the error.

The following shows several service calls, any one of which may raise an error, along with possible ways to deal with the error:

howcast =
  howcast.user :id => "kreektrebano", :resource => :videos
  howcast.user :id => "jurisgalang",  :resource => :favorite
  howcast.videos :sort   => :most_recent, 
                 :filter => :all, 
                 :page   => 99999999
rescue Howkast::Error::UserNotFound
  # ignore
rescue Howkast::Error::HTTP404
  # ignore but log, this is raised if the resource requested is not found;
  # eg: specifying a :resource that is not supported, or the :page requested
  # does not exist
rescue Howkast::Error::InvalidAPIKey
  # the service call requires registration and a valid API key to work
rescue Howkast::Error::HTTP500
  # ignore but log and file a bug at 

Of the above Howkast::Error::UserNotFound and Howkast::Error::HTTP404 are most likely benign.

Read the HTTP Status Codes and Errors section of the Howcast API Documentation for details on the types of errors that may be encountered.


Currently, Howcast responds with an HTTP500 error when the :q parameter value is empty. To get around this the #search service plugs this parameter with something that might not exist and hopefully it returns an appropriate search result (ie: an empty list)

It does not support Ruby 1.8.6


You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

git clone git://

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.


Please read the RELEASENOTES file for the details of each release.

In general: patch releases will not include breaking changes while releases that bumps the major or minor components of the version string may or may not include breaking changes.


Juris Galang


Dual licensed under the MIT or GPL Version 2 licenses.
See the MIT-LICENSE and GPL-LICENSE files for details.

Copyright (c) 2010 Juris Galang. All Rights Reserved.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more