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 🙏

© 2026 – Pkg Stats / Ryan Hefner

oembed.js

v1.0.8

Published

oEmbed implementation for JavaScript

Readme

oembed.js

oembed.js is a JavaScript implementation of the oEmbed format.

Features

  • Fetch oEmbed data for websites

Installing

npm install oembed.js

API

The oembed.js class needs to be initialized with a list of providers. It is recommended to use the provider list from oEmbed itself: https://oembed.com/providers.json. You can also supply your own list or, if you don't want to use the provider lookup, use an empty array (new oEmbed([])).

Constructor

The constructor takes two arguments: providers and an optional config.

| Parameter | Type | Description | | ----------- | ----------- | ----------- | | providers | object[] | An array with the provider syntax (see below) | config | object | A config object with the config syntax (see below)

Provider syntax

Asterisks represent a wildcard.

{
    "provider_name": "lars.koelker.dev",
    "provider_url": "https://lars.koelker.dev",
    "endpoints": [
      {
        "schemes": [
          "https:/lars.koelker.dev/*"
        ],
        "url": "https:/lars.koelker.dev/oembed"
      }
    ]
}

Config syntax

| Config entry | Type | Description | | ----------- | ----------- | ----------- | | format | string | Response format. Either json (default) or xml. | | maxWidth | number|undefined | Maximum width (defaults to undefined). | | maxHeight | number|undefined | Maximum height (defaults to undefined). | | oembedParameters| object |Parameters that will be applied to an endpoint (see syntax below).|

oembedParameters syntax

Some providers (e.g. Facebook) use parameters that are not defined in the official oEmbed specification. You can supply these by origin here.

{
    '<URL_ORIGIN>': { // e.g. 'https://graph.facebook.com'
        '<PARAMETER_NAME>': '<PARAMETER_VALUE>' // e.g. 'acess_token': '12|34'
    }
}

The <URL_ORIGIN> should match with the origin of an endpoint url. For example one of Facebooks endpoints has the url https://graph.facebook.com/v10.0/oembed_post. The origin would be https://graph.facebook.com.

Method async getProviderUrl(url): Promise<string[]>

This method fetches the given url and checks whether it has a <link rel="alternate"> tag or link header for oEmbed data. If a tag or header is found, the method will return a Promise<string[]>, otherwise an empty Promise<string[]>.

This method does not check the providers list.

Method async getData(url, useProviderLookup=true): Promise<object | null>

This method will check the given providers list for the url host. If the host is not inside the providers list, the given host of url will be fetched and checked for an oEmbed url, if useProviderLookup is enabled. metaAppId can either be specified in the initial config or using the parameter as a fallback.

If no oEmbed url was found, Promise<null> will be returned, otherwise an Promise<object> with the fetched data.

Example

The following code will get the oembed data for https://lars.koelker.dev. We also supply a maxWidth and maxHeight which should be respected by the oEmbed endpoints (https://lars.koelker.dev doesn't though).

const oEmbed = require("oEmbed.js");
const axios = require("axios");

(async () => {
    const providers = await axios.get('https://oembed.com/providers.json');
    const oe = new oEmbed(providers.data, {
        maxWidth: 420,
        maxHeight: 69
    });
    const response = await oe.getData('https://lars.koelker.dev');
    
    console.log(response);
})()