Giter Club home page Giter Club logo

oembed-spec's Introduction

microlink logo

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

oembed-spec's People

Contributors

dependabot-preview[bot] avatar kikobeats avatar remusao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.