Skip to content

An enriched oEmbed API for the major media platforms.

Notifications You must be signed in to change notification settings

luwes/playerx-oembed

Repository files navigation

PlayerX oEmbed

Uses the media platform's oEmbed API when possible and enriches the response with useful metadata / structured data from the content URL using Cloudflare workers.

The following metadata is added if possible; upload_date, duration, content_url, embed_url.

If the provider offers inline and iframe embeds like Wistia or Brightcove this API will output the inline embed code. This is most performant and gives the developer more control over video playback.

Quick Example

A consumer makes the following HTTP request:

The provider then responds with an oEmbed response:

{
  "version": "1.0",
  "type": "video",
  "provider_name": "Wistia, Inc.",
  "provider_url": "https://wistia.com",
  "title": "The World In HDR 4K",
  "duration": 115.434,
  "upload_date": "2021-11-21T23:27:19.000Z",
  "thumbnail_url": "https://embed-ssl.wistia.com/deliveries/e3479c070161f77ff5b379a17ee91c1f.jpg?image_crop_resized=960x540",
  "thumbnail_width": 960,
  "thumbnail_height": 540,
  "html": "\n<div class=\"wistia_embed wistia_async_oifkgmxnkb\" id=\"plx318\"></div>\n<script src=\"https://fast.wistia.com/assets/external/E-v1.js\"></script>\n<script>\nwindow._wq.push({\n  id: 'oifkgmxnkb',\n  options: {},\n  onReady: function(api) {\n    (api);\n  }\n});\n</script>\n",
  "width": 960,
  "height": 540,
  "player_color": "174bd2"
}

Extra End Points

/render

Provides a HTML page with only the video player embedded on it. This URL is typically used for an iframe embed.
https://api.playerx.io/render?url=https%3A%2F%2Fwesleyluyten.wistia.com%2Fmedias%2Foifkgmxnkb

/html

Returns the raw html snippet from the oEmbed response. Useful for embedding in another document. https://api.playerx.io/html?url=https%3A%2F%2Fwesleyluyten.wistia.com%2Fmedias%2Foifkgmxnkb

Consumer Request

Requests sent to the API endpoint must be HTTP GET requests, with all arguments sent as query parameters. All arguments must be urlencoded (as per RFC 1738).

The following query parameters are defined as part of the oEmbed spec:

param description
url Required. The URL to retrieve embedding information for.
maxwidth The maximum width of the embedded resource.
maxheight The maximum height of the embedded resource.
seo If seo=1, structured data in JSON-LD format is appended to the html property. The structured data adds SEO (Search engine optimization) to the media's embed code.
fields Filter the response properties based on the fields param. Comma separated. For example fields=title,thumbnail_url,html
api If api=1, the associated player API will be enabled via an added script. Use together with callback to set up a controllable player.
callback Set to a global JS function that can be called on the page which is passed the instance of the enabled player API. e.g. api=1&callback=console.log

These are the supported URL params in the Playerx oEmbed layer but many media platform's oEmbed API support additional URL params. For example Vimeo supports: width, height, byline, title, portrait, color, autoplay, loop, muted etc.

Purge cached resource

curl -X POST "https://api.playerx.io/oembed?url=https%3A%2F%2Fvimeo.com%2F357274789" \
-H "X-Purge: 1"

Supported Providers

Supported providers so far (feel free to open a PR):

Used by

Thanks

Releases

No releases published

Packages

No packages published