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

spotify-url-info

v3.2.13

Published

Get metadata from Spotify URLs

Downloads

51,380

Readme

Last version Coverage Status NPM Status

Get metadata from Spotify URLs.

Install

npm install spotify-url-info

Usage

In order to use the library, you have to provide the fetch agent to use:

const fetch = require('isomorphic-unfetch')
const { getData, getPreview, getTracks, getDetails } =
  require('spotify-url-info')(fetch)

There are four functions:

  • getData Provides the full available data, in a shape that is very similar to what the spotify API returns.

  • getPreview Always returns the same fields for different types of resources (album, artist, playlist, track). The preview track is the first in the Album, Playlist, etc.

  • getTracks Returns array with tracks. This data is passed on straight from spotify, so the shape could change.Only the first 100 tracks will be returned.

  • getDetails Returns both the preview and tracks. Should be used if you require information from both of them so that only one request is made.

All the methods receive a Spotify URL (play. or open.) as first argument:

getPreview('https://open.spotify.com/track/5nTtCOCds6I0PHMNtqelas').then(data =>
  console.log(data)
)

Additionally, you can provide fetch agent options as second argument:

getPreview('https://open.spotify.com/track/5nTtCOCds6I0PHMNtqelas', {
  headers: {
    'user-agent': 'googlebot'
  }
}).then(data => console.log(data))

It returns back the information related to the Spotify URL:

{
  "title": "Immaterial",
  "type": "track",
  "track": "Immaterial",
  "artist": "SOPHIE",
  "image": "https://i.scdn.co/image/d6f496a6708d22a2f867e5acb84afb0eb0b07bc1",
  "audio": "https://p.scdn.co/mp3-preview/6be8eb12ff18ae09b7a6d38ff1e5327fd128a74e?cid=162b7dc01f3a4a2ca32ed3cec83d1e02",
  "link": "https://open.spotify.com/track/5nTtCOCds6I0PHMNtqelas",
  "embed": "https://embed.spotify.com/?uri=spotify:track:5nTtCOCds6I0PHMNtqelas",
  "date": "2018-06-15T00:00:00.000Z",
  "description": "description of a podcast episode"
}

When a field can't be retrieved, the value will be undefined.

There are no guarantees about the shape of this data, because it varies with different media and scraping methods. Handle it carefully.

License

spotify-url-info © microlink.io, released under the MIT License. Authored by Karl Sander and maintained by Kiko Beats with help from contributors.

microlink.io · GitHub microlink.io · Twitter @microlinkhq