oEmbed protocol

oEmbed format lets you embed the player with a coub video when a user posts a link to it in your web application or site.

To embed a coub video using the oEmbed player you need to make an HTTP request containing a URL of the required video to the Coub endpoint. The endpoint responses with a JSON or an XML data that contains an HTML code for video embedding and data about the required video.

By the way, Embedly service supports coubs.

Endpoint

Coub provides two oEmbed endpoints: one that responses with JSON data, and one that responses with XML data.

The URL of the JSON endpoint:

http://coub.com/api/oembed.json

The URL of the XML endpoint:

http://coub.com/api/oembed.xml

The endpoint accepts url parameter that should contain a URL to a coub video with following scheme:

http://coub.com/view/:permalink
  • permalink (string) — the permalink of the needed coub video.

Apart from the coub video's URL endpoints also accepts several parameters:

  • autoplay (boolean) — whether the embeded video should start automatically after loading, by default is set to false;
  • maxwidth (integer) — the maximum width of the embeded video;
  • maxheight (integer) — the maximum height of the embeded video.

Here is an example of the valid HTTP request to the oEmbed endpoint:

GET http://coub.com/api/oembed.json?url=http%3A//coub.com/view/um0um0&autoplay=true&maxwidth=500&maxheight=500

Response

The endpoint responses on requests with a JSON or an XML data that contains several fields:

  • type (string) — the resource type, is always set to video;
  • version (float) — the oEmbed version number, is always set to 1.0;
  • width (integer) — the width of the embedded video;
  • height (integer) — the height of the embedded video;
  • title (string) — the title of the video;
  • url (string) — the coub URL of the video;
  • thumbnail_url (string) — the URL to the video's thumbnail picture;
  • thumbnail_width (integer) — the width of the video's thumbnail picture;
  • thumbnail_height (integer) — the height of the video's thumbnail picture;
  • author_name (string) — the title of the channel that the video is belongs to;
  • channel_url (string) — the URL of the channel that the video is belongs to;
  • provider_name (string) — the name of the resource provider, is always set to Coub;
  • provider_url (string) — the URL of the resource provider, is always set to http://coub.com/;
  • html (string) — the HTML code that embeds an iframe player with the required coub video and parameters.

Here is the JSON response example:

{
    "type": "video",
    "version": "1.0",
    "width": "450",
    "height": "360",
    "title": "Dear diary...",
    "url": "http://coub.com/view/2hb98",
    "thumbnail_url": "http://ell.akamai.coub.com/get/bucket:22.31/p/coub/simple/cw_image/b536fe74cf3/c79a0b057d948743f17b4/med_1405385699_00032.jpg",
    "thumbnail_width": "450",
    "thumbnail_height": "360",
    "author_name": "costruendo l'alba",
    "channel_url": "http://coub.com/d608ae26dad95db0aa47655081171555",
    "provider_name": "Coub",
    "provider_url": "http://coub.com/",
    "html": "<iframe src=\"http://coub.com/embed/um0um0\" allowfullscreen=\"true\" frameborder=\"0\" width=\"640\" height=\"512\"></iframe>"
}