npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

embedify

v4.0.8

Published

oEmbed library for Soundcloud, Spotify, Vimeo and Youtube

Downloads

147

Readme

Embedify

Simple and robust oEmbed library. Fetches oEmbed information for Soundcloud, Spotify, Vimeo and Youtube links. The library is highly modular and new providers can be added easily (contributions welcome).

Installing

npm install embedify

Usage

const embedify = require('embedify');

const options = { parse: true };
const oEmbed = embedify.create(options);

const urls = [
  'https://www.youtube.com/embed/iOf7CsxmFCs',
  'https://play.spotify.com/track/4th1RQAelzqgY7wL53UGQt',
];

oEmbed.get(urls)
  .then(res => console.log(res));

Result

[{ 
  type: 'video',
  version: '1.0',
  title: '☼ Min sommer road trip | Del 1 ☼',
  html: '<iframe width="480" height="270" src="https://www.youtube.com/embed/iOf7CsxmFCs?feature=oembed" frameborder="0" allowfullscreen></iframe>',
  author: { 
    name: 'Amanda MIDK',
    url: 'https://www.youtube.com/user/AmandaS4G'
  },
  provider: { 
    name: 'YouTube', 
    url: 'https://www.youtube.com/' 
  },
  image: { 
    url: 'https://i.ytimg.com/vi/iOf7CsxmFCs/hqdefault.jpg',
    width: 480,
    height: 360 
  },
  width: 480,
  height: 270
},
{  
  type: 'rich',
  version: '1.0',
  title: 'Avicii - The Days',
  html: '<iframe src="https://embed.spotify.com/?uri=spotify:track:4th1RQAelzqgY7wL53UGQt" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>',
  author: {},
  provider: { 
    name: 'Spotify', 
    url: 'https://www.spotify.com' 
  },
  image: { 
    url: 'https://d3rt1990lpmkn.cloudfront.net/cover/f8717f432506ab213c4de0c66d6ac24cd07ecf72',
    width: 300,
    height: 300 
  },
  width: 300,
  height: 380
}]

API

embedify.create([options])

Creates new Embedify instance.

options

parse

Type: boolean Default: true

By default, the provider's response will be parsed and the following schema is ensured:

[{ 
  type: string,
  version: string,
  title: string,
  html: string,
  author: {
    name: string,
    url: string,
  },
  provider: {
    name: string,
    url: string,
  },
  image: {
    url: string,
    width: number,
    height: number,
  },
  width: number,
  height: number,
}]

If parse is set to false the raw response will be returned instead, like for example:

[{
  provider_url: 'https://www.spotify.com',
  version: '1.0',
  thumbnail_width: 300,
  height: 380,
  thumbnail_height: 300,
  title: ' - ',
  width: 300,
  thumbnail_url: 'https://d3rt1990lpmkn.cloudfront.net/cover/',
  provider_name: 'Spotify',
  type: 'rich',
  html: '<iframe src="https://embed.spotify.com/?uri=spotify:track:sdfgerh" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>'
}]
failSoft

Type: boolean Default: false

By default, 404 responses from provider APIs (when for example a video has been removed from Youtube etc.) will make Embedify reject the Promise with a ProviderRequestError. In cases where an empty result is preferred, failSoft can be set to true and Embedify will resolve normally with no/empty result for that particular URL.

concurrency

Type: number Default: 10

Sets the maximum number of concurrent HTTP requests to provider APIs.

oEmbed.get(urls)

Returns a Promise and resolves to oEmbed information for all URLs that matched a provider.

urls

Type: string or array<string>

URL or list of URLs to get oEmbed information for.