All Projects → idanlo → React Spotify Api

idanlo / React Spotify Api

Licence: mit
A React component library that makes it easier to interact with the Spotify API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Spotify Api

Spotify Web Api Kotlin
Spotify Web API wrapper for Kotlin/JVM, Kotlin/Android, Kotlin/JS, and Kotlin/Native. Includes a Spotify Web Playback SDK wrapper for Kotlin/JS, and a spotify-auth wrapper for Kotlin/Android
Stars: ✭ 86 (-63.71%)
Mutual labels:  spotify-api
Spotify.py
🌐 API wrapper for Spotify 🎶
Stars: ✭ 131 (-44.73%)
Mutual labels:  spotify-api
Obscurify
Find out more about your music taste and compare it to others' with Obscurify
Stars: ✭ 200 (-15.61%)
Mutual labels:  spotify-api
Spotify Web Api Js
A client-side JS wrapper for the Spotify Web API
Stars: ✭ 1,313 (+454.01%)
Mutual labels:  spotify-api
Spotify Dart
A dart library for interfacing with the Spotify API.
Stars: ✭ 109 (-54.01%)
Mutual labels:  spotify-api
Tune
A streamlined Spotify client and browser with a focus on performance and integrations.
Stars: ✭ 166 (-29.96%)
Mutual labels:  spotify-api
Chaseohlson
🤠 My website, built with Gatsby, Styled-Components & DatoCMS
Stars: ✭ 75 (-68.35%)
Mutual labels:  spotify-api
Savify
Download Spotify songs to mp3 with full metadata and cover art!
Stars: ✭ 227 (-4.22%)
Mutual labels:  spotify-api
Soundize
🎧 A homemade Spotify application. It's a server side rendering client made with React and Redux, powered by the Spotify API
Stars: ✭ 121 (-48.95%)
Mutual labels:  spotify-api
Angular Quiz App
A music quiz in Angular 2+ using the Spotify API.
Stars: ✭ 180 (-24.05%)
Mutual labels:  spotify-api
Pasta For Spotify
A material design Spotify client for Android
Stars: ✭ 93 (-60.76%)
Mutual labels:  spotify-api
Exportify
Export/Backup Spotify playlists using the Web API
Stars: ✭ 1,611 (+579.75%)
Mutual labels:  spotify-api
Coverify
🎧 Design fresh album cover for your Spotify playlists
Stars: ✭ 167 (-29.54%)
Mutual labels:  spotify-api
Whisperify
An interactive way to learn about your favourite songs on Spotify. Quiz yourself on your favourite playlists and share quizzes with friends.
Stars: ✭ 91 (-61.6%)
Mutual labels:  spotify-api
Spotify Graphql
GraphQL schema for Spotify WebAPI — TypeScript / Node.js (v6)
Stars: ✭ 213 (-10.13%)
Mutual labels:  spotify-api
Exportify
Export Spotify playlists using the Web API. Analyze them in the Jupyter notebook.
Stars: ✭ 80 (-66.24%)
Mutual labels:  spotify-api
Listen Now
Listen-now, 提供了多音乐平台的音乐搜索、播放、歌单播放、同步平台歌单到本地数据库,并计划开发智能音乐推荐系统。listen-now主要由学生层级的同学一起开发。
Stars: ✭ 139 (-41.35%)
Mutual labels:  spotify-api
Swift Radio Pro
Professional Radio Station App for iOS!
Stars: ✭ 2,644 (+1015.61%)
Mutual labels:  spotify-api
Spotify Qt
Lightweight Spotify client using Qt
Stars: ✭ 212 (-10.55%)
Mutual labels:  spotify-api
Spotify Now Playing
Spotify now playing information and control popup for macOS menu bar
Stars: ✭ 171 (-27.85%)
Mutual labels:  spotify-api

react-spotify-api

A component library that helps you interact with the Spotify API

Demo

NPM Build Status Dependencies Dev Dependencies Peer Dependencies Codecov npm bundle size (minified) GitHub PRs Welcome

Documentation

Features

  • Components for most of Spotify's data types that pass data through render props
  • Hooks for most of Spotify's data

Roadmap

  • [x] Pass Spotify data with render props
  • [x] Use React.Context to pass the access token down the component tree
  • [x] Hooks!
  • [x] A demo page that uses this library - available here!
  • [x] Load more data support (infinite scrolling) - current works for some of the data types
  • [ ] TypeScript support!
  • [ ] 100% code coverage
  • [ ] Hooks for all data types from Spotify's API
  • [ ] Hooks for using the Spotify Playback SDK

Version 3.0.0 Breaking Change

Before version 3.0.0 the parameters to props.children were passed in this order - data, loading, error. It is now passed as an object, so you would now use the Album component like this -

<Album id={...}>
  {({ data }) => {
    return <></>;
  }}
</Album>

As opposed to the previous versions where you would use the components like this -

<Album id={...}>
  {(data, loading, error) => {
    return <></>;
  }}
</Album>

This way you can choose which parameters you would like to have, and if you want just the error parameter you can omit the other two. This works well with the loadMoreData parameter, you don't need to write all 4 parameters if you just need some of them.

Installing

with npm

npm install --save react-spotify-api

with yarn

yarn add react-spotify-api

Wrapping your app with a Provider

in order to use the Spotify API you are required to send an access token (read more here) with every single http request, but the SpotifyApiContext provider does that for you!

Import

import { SpotifyApiContext } from 'react-spotify-api';

Wrap your app with it (all react-spotify-api components must have a SpotifyApiContext.Provider parent)

<SpotifyApiContext.Provider value={token}>
  <App />
</SpotifyApiContext.Provider>

You can now use all components without worrying about getting your access token!

Component usage

import React, { Component } from 'react';

import { SpotifyApiContext, Artist } from 'react-spotify-api';

function Example(props) {
  return (
    <SpotifyApiContext.Provider value={props.token}>
      <Artist id={props.id}>
        {({ data, loading, error }) =>
          data ? (
            <div>
              <h1>{data.name}</h1>
              <ul>
                {data.genres.map(genre => (
                  <li key={genre}>{genre}</li>
                ))}
              </ul>
            </div>
          ) : null
        }
      </Artist>
    </SpotifyApiContext.Provider>
  );
}

Hooks usage (assuming the ExampleHooks component is wrapped with the SpotifyApiContext.Provider)

import React from 'react';

import { useArtist } from 'react-spotify-api';

function ExampleHooks(props) {
  const { data, loading, error } = useArtist(props.id);

  return artist ? (
    <div>
      <h1>{artist.name}</h1>
      <ul>
        {artist.genres.map(genre => (
          <li key={genre}>{genre}</li>
        ))}
      </ul>
    </div>
  ) : null;
}

Data types

  • data - Each component has a link to the Spotify API endpoint where you can see the data model for that specific data type
  • loading - Boolean (true when loading and false when finished loading)
  • error - null when there are no errors but an object when there are - usually containing the error object received by the fetch api, so it looks something like: {status: 404, message: "Not Found"}

License

This project is licensed under the MIT License - see the LICENSE file for details

MIT © idanlo

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].