Skip to main content

A Python library for oEmbed that supports auto-discovered and manually included providers.

Project description

A Python library for oEmbed that supports auto-discovered and manually included providers.


$ pip install pyoembed


The library provides a function that should be called to automatically embed the url content, and it is called oEmbed:

from pyoembed import oEmbed, PyOembedException

    # maxwidth and maxheight are optional.
    data = oEmbed('',
                  maxwidth=640, maxheight=480)
except PyOembedException, e:
    print 'An error was ocurred: %s' % e

# data is a dict with keys that will depends on the media type. You should
# choose how to display the content based on the data['type'] value and
# the oEmbed spec ( ).
if data['type'] == 'video':
    print data['html']

# and it goes... Someday we will provide default renderes for each media
# type.

Addition of new providers

pyoembed tries to cover the major oEmbed providers, and should works for any provider that supports oEmbed auto-discover out-of-the box, however your favorite provider may be unsupported yet! :(

To add it, create a file inside the pyoembed.providers package, based on the following example:

from pyoembed.providers import BaseProvider

class InstagramProvider(BaseProvider):

    # priority of the provider. Increase it if the provider isn't well known
    priority = 10

    # url schemas that are supported by the provider.
    # re.compile'd regex are allowed.
    oembed_schemas = ['*',

    # api endpoint that answers to oEmbed requests for the provider.
    oembed_endpoint = ''

You will also need to add some test urls of your provider to the file, and run it to see if everything is ok.

If everything works, feel free to send a pull request to add the provider:

That’s it!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyoembed-0.1.2.tar.gz (12.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page