New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

oembed-parser

Package Overview
Dependencies
Maintainers
3
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oembed-parser

Get oEmbed data from given URL.

  • 1.5.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
679
decreased by-76.74%
Maintainers
3
Weekly downloads
 
Created
Source

oembed-parser

Extract eEmbed content from given URL.

NPM CI test Coverage Status Quality Gate Status JavaScript Style Guide

Important note:

Demo

Installation

npm install oembed-parser

Usage

import {
  extract
} from 'oembed-parser'

const url = 'https://www.youtube.com/watch?v=8jPQjjsBbIc'

extract(url).then((oembed) => {
  console.log(oembed)
}).catch((err) => {
  console.trace(err)
})

APIs

.extract(String url [, Object params])

Extract oEmbed data from specified url. Return: a Promise

Optional argument params is an object with it we can set maxwidth and/or maxheight those are used to scale embed size to fit your container size. Please refer oEmbed/Full Spec/Consumer Request for more info.

Here is how we can use oembed-parser in async/await style:

import {
  extract
} from 'oembed-parser'

const getOembed = async (url) => {
  try {
    const oembed = await extract(url)
    return oembed
  } catch (err) {
    console.trace(err)
  }
}

const data = getOembed('your url')
console.log(data)
.hasProvider(String URL)

Return boolean. True if the URL matches with any provider in the list.

.setProviderList(Array of provider definitions)

Sets the list of providers to use, overriding the defaults.

This can be useful for whitelisting only certain providers, or for adding custom providers.

For the expected format, see the default list.

Provider list

List of resource providers is a clone of oembed.com and available here.

Changes with Instagram

Since October 24 2020, Facebook have deprecated their legacy urls and applied a new Facebook oEmbed endpoints. Please update your oembed-parser version to v1.4.2 to be able to extract Instagram links.

Technically, now we have to use Facebook Graph API, with the access token from a valid and live Facebook app. By default, oembed-parser build Graph API endpoint using a pre-existing access token. Althrough it should work in almost cases. However, we recommend to add your own ones.

export FACEBOOK_APP_ID=your_app_id
export FACEBOOK_CLIENT_TOKEN=your_client_token

For more info, please refer:

Test

git clone https://github.com/ndaidong/oembed-parser.git
cd oembed-parser
npm install
npm test

# quick evaluation
npm run eval {URL_TO_PARSE_OEMBED}

License

The MIT License (MIT)

Keywords

FAQs

Package last updated on 07 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc