Created: 2008-05-09 13:50
Updated: 2019-02-14 21:45
License: mit


Gem Travis branch Code Climate Coveralls Maintenance

An oEmbed consumer library written in Ruby, letting you easily get embeddable HTML representations of supported web pages, based on their URLs. See for more about the protocol.


gem install ruby-oembed

Get Started

Built-in Providers

The easiest way to use this library is to make use of the built-in providers.

resource = OEmbed::Providers.get('') #=> true
resource.thumbnail_url #=> ""
resource.html #=> <<-HTML
  <object width="425" height="344">
    <param name="movie" value=""></param>
    <param name="allowFullScreen" value="true"></param>
    <param name="allowscriptaccess" value="always"></param>
    <embed src="" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="always" allowfullscreen="true"></embed>

Custom Providers

If you'd like to use a provider that isn't included in the library, it's easy to create one. Just provide the oEmbed API endpoint and URL scheme(s).

my_provider ="{format}")
my_provider << "http://**"
my_provider << "http://**"

You can then use your new custom provider or you can register it along with the rest of the built-in providers.

resource = my_provider.get("") #=> OEmbed::Response #=> "My Cool Service"

resource = OEmbed::Providers.get("") #=> OEmbed::Response

Fallback Providers

Last but not least, ruby-oembed supports Noembed, Embedly, provider discovery. The first two are provider aggregators. Each supports a wide array of websites ranging from to xkcd. The later is part of the oEmbed specification that allows websites to advertise support for the oEmbed protocol.

OEmbed::Providers.get('') #=> OEmbed::Response


This library works wonderfully on its own, but can get a speed boost by using 3rd party libraries to parse oEmbed data. To use a 3rd party Formatter, just be sure to require the library before ruby-oembed (or include them in your Gemfile before ruby-oembed).

require 'json'
require 'xmlsimple'
require 'oembed'

OEmbed::Formatter::JSON.backend #=> OEmbed::Formatter::JSON::Backends::JSONGem
OEmbed::Formatter::XML.backend  #=> OEmbed::Formatter::XML::Backends::XmlSimple

The following, optional, backends are currently supported:

Lend a Hand

Note: Work is under way on a v1.0 of ruby-oembed. If you'd like to contribute, take a look at the rubocop branch!

Code for the ruby-oembed library is hosted on GitHub.

# Get the code.
git clone git://
cd ruby-oembed
# Install all development-related gems.
gem install bundler
bundle install
# Run the tests.
bundle exec rake
# or run the test continually
bundle exec guard

If you encounter any bug, feel free to create an Issue.

We gladly accept pull requests! Just fork the library and commit your changes along with relevant tests. Once you're happy with the changes, send a pull request.

We do our best to keep our tests green


Thanks to all who have made contributions to this gem, both large and small.


This code is free to use under the terms of the MIT license.

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