A parser for oEmbed specification.
- Always on sync with oEmbed providers (as npm postinstall hook).
- Handle http/https & www/non-www URLs variations.
- Ability to pass extra oEmbed parameters.
- Built for speed (see benchmarks).
$ npm install oembed-spec --save
const oEmbed = require('oembed-spec')
// Just pass the URL
oEmbed('https://youtu.be/I8u2NdWuaYs')
// {
// provider_name: 'YouTube',
// author_url: 'https://www.youtube.com/user/mirandaskiss'
// html: '<iframe width="480" height="270" src="https://www.youtube.com/embed/I8u2NdWuaYs?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
// }
// http/https and www/non-www are handled
oEmbed('http://www.youtu.be/I8u2NdWuaYs')
// {
// provider_name: 'YouTube',
// author_url: 'https://www.youtube.com/user/mirandaskiss'
// html: '<iframe width="480" height="270" src="https://www.youtube.com/embed/I8u2NdWuaYs?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
// }
// Pass specific oEmbed options as second parameter
oEmbed('http://www.youtu.be/I8u2NdWuaYs', { maxheight: 612 })
// {
// provider_name: 'YouTube',
// author_url: 'https://www.youtube.com/user/mirandaskiss'
// html: '<iframe width="480" height="270" src="https://www.youtube.com/embed/I8u2NdWuaYs?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
// }
Required
Type: string
A valid WHATWG URL.
Any option present will be passed against the consumer request (see oembed.com section 2.2).
Any option present will be passed to got.
Standalone method for finding a provider.
Standalone method for fetching an specific provider.
oembed-spec © microlink.io, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.
microlink.io · GitHub microlink.io · X @microlinkhq