1.3.30 • Published 8 months ago

oembed-spec v1.3.30

Weekly downloads
251
License
MIT
Repository
github
Last release
8 months ago

Last version Coverage Status NPM Status

A parser for oEmbed specification.

Features

  • 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).

Install

$ npm install oembed-spec --save

Usage

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>'
// }

API

oEmbed(input, options, gotOpts)

input

Required Type: string

A valid WHATWG URL.

options

Any option present will be passed against the consumer request (see oembed.com section 2.2).

gotOpts

Any option present will be passed to got.

.findProvider(url)

Standalone method for finding a provider.

.fetchProvider(provider, url, opts, gotOpts)

Standalone method for fetching an specific provider.

License

oembed-spec © microlink.io, released under the MIT License. Authored and maintained by Kiko Beats with help from contributors.

microlink.io · GitHub microlink.io · Twitter @microlinkhq

1.3.30

8 months ago

1.3.29

12 months ago

1.3.28

1 year ago

1.3.27

1 year ago

1.3.26

2 years ago

1.3.24

2 years ago

1.3.25

2 years ago

1.3.23

2 years ago

1.3.21

2 years ago

1.3.22

2 years ago

1.3.20

3 years ago

1.3.19

3 years ago

1.3.18

4 years ago

1.3.17

4 years ago

1.3.16

4 years ago

1.3.15

4 years ago

1.3.14

4 years ago

1.3.13

4 years ago

1.3.12

4 years ago

1.3.11

4 years ago

1.3.10

4 years ago

1.3.9

4 years ago

1.3.8

4 years ago

1.3.7

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago