Skip to main content

Python Library for Embedly

Project description

Python Library for interacting with Embedly's API. To get started sign up for
a key at ` <>`_.

Install with `Pip <>`_ (recommended)::

pip install -e git://

Or setuptools::

git clone git://
sudo python

Getting Started
This library is meant to be a dead simple way to interact with the Embedly API.
There are only 2 main objects, the ``Embedly`` client and the ``Url`` model.
Here is a simple example and then we will go into the objects::

>>> from embedly import Embedly
>>> client = Embedly(:key)
>>> obj = client.oembed('')
>>> obj.type
>>> obj['type']
>>> obj.url

>>> obj = client.oembed('')
>>> obj.error

Embedly Client
The Embedly client is a object that takes in a key and an optional User Agent
then handles all the interactions and HTTP requests to Embedly. To initialize
the object pass in your key you go from signing up for Embedly and an optional
User Agent.

>>> from embedly import Embedly
>>> client = Embedly('key', 'Mozilla/5.0 (compatible; example-org;)')

The client object now has a bunch of different methods that you can use.

Corresponds to the `oEmbed endpoint
<>`_. Passes back a simple object that
allows you to retrieve a title, thumbnail, description and the embed html::

>>> client.oembed('')
<embedly.models.Url at 0x10223d950>

Corresponds to the `Preview endpoint
<>`_. Passes back a simple object
that allows you to retrieve a title, description, content, html and a list of

>>> client.preview('')
<embedly.models.Url at 0x10223d950>

Corresponds to the `Objectify endpoint
<>`_. Passes back a simple object
that allows you to retrieve pretty much everything that Embedly knows about a

>>> client.objectify('')
<embedly.models.Url at 0x10223d950>

The above functions all take the same arguements, a URL or a list of URLs and
keyword arguments that correspond to Embedly's `query arguments
<>`_. Here are a few examples::

>>> client.oembed(['',
''], maxwidth=500, words=20)

There are some supporting functions that allow you to limit urls before sending
them to Embedly. Embedly can return metadata for any URL, these just allow a
developer to only pass a subset of Embedly `providers
<>`_. Note that URL shorteners like or are
not supported through these regexes.

If you would like to only send URLs that return embed HTML via Embedly you
can match the URL to the regex before making the call. The matching providers
are listed at ` <>`_::

>>> url = ''
>>> client.regex.match(url)
<_sre.SRE_Match at 0x1017ba718>

This is a simplified version of ``regex``::

>>> url = ''
>>> client.is_supported(url)

Url Object
The ``Url`` Object is just a smart dictionary that acts more like an object.
For example when you run ``oembed`` you get back a Url Object:

>>> obj = client.oembed('', words=10)

Depending on the method you are using, the object has a different set of
attributes. We will go through a few, but you should read the `documentation
<>`_ to get the full list of data that is passed back.::

# Url Object can be accessed like a dictionary
>>> obj['type']
# Data can also be accessed like attributes
>> obj.type
# Invalid attributes are returned as None
>>> obj.notanattribute

# The url object always has an ``orginal_url`` attrbiute.
>>> obj.original_url
# The method used to retrive the URL is also on the obj
>>> obj.method

For the Preview and Objectify endpoints the sub objects can also be accessed in
the same manner.

>>> obj = client.preview('', words=10)
>>> obj.object.type
>>> obj.images[0].url

Error Handling
If there was an error processing the request, The ``Url`` object will contain
an error. For example if we use an invalid key, we will get a 401 response back

>>> client = Embedly('notakey')
>>> obj = client.preview('', words=10)
>>> obj.error
>>> obj.error_code

Copyright (c) 2011, Inc. See LICENSE for details.

Project details

Download files

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

Files for Embedly, version 0.4
Filename, size File type Python version Upload date Hashes
Filename, size Embedly-0.4.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page