Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/microlinkhq/oembed-spec
- Owner: microlinkhq
- License: mit
- Created: 2020-01-01T19:07:04.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-28T17:27:03.000Z (12 months ago)
- Last Synced: 2024-09-19T12:48:37.232Z (4 months ago)
- Topics: oembed
- Language: JavaScript
- Size: 189 KB
- Stars: 16
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome-list - oembed-spec
README
![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)