Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/microlinkhq/oembed-spec

A parser for oEmbed specification.
https://github.com/microlinkhq/oembed-spec

oembed

Last synced: 2 months ago
JSON representation

A parser for oEmbed specification.

Awesome Lists containing this project

README

        


microlink logo
microlink logo




![Last version](https://img.shields.io/github/tag/microlinkhq/oembed-spec.svg?style=flat-square)
[![Coverage Status](https://img.shields.io/coveralls/microlinkhq/oembed-spec.svg?style=flat-square)](https://coveralls.io/github/microlinkhq/oembed-spec)
[![NPM Status](https://img.shields.io/npm/dm/oembed-spec.svg?style=flat-square)](https://www.npmjs.org/package/oembed-spec)

> A parser for oEmbed specification.

## Features

- Always on sync with [oEmbed providers](https://oembed.com/providers.json) (as npm postinstall hook).
- Handle http/https & www/non-www URLs variations.
- Ability to pass extra oEmbed parameters.
- Built for speed (see [benchmarks](benchmarks/README.md)).

## Install

```bash
$ npm install oembed-spec --save
```

## Usage

```js
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: ''
// }

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

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

## 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](https://oembed.com) section 2.2).

#### gotOpts

Any option present will be passed to [got](https://github.com/sindresorhus/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](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/oembed-spec/blob/master/LICENSE) License.

Authored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/microlinkhq/oembed-spec/contributors).

> [microlink.io](https://microlink.io) · GitHub [microlink.io](https://github.com/microlinkhq) · Twitter [@microlinkhq](https://twitter.com/microlinkhq)