Giter Site home page Giter Site logo

marsidev / spotify-badge Goto Github PK

View Code? Open in Web Editor NEW

This project forked from akellbl4/spotify-badge

0.0 0.0 0.0 982 KB

๐Ÿ‘ฉโ€๐ŸŽค Share your love to music with the world ๐ŸŒ. Put Spotify badge in any place where you can post an image.

Home Page: https://spotify-badge.vercel.app

TypeScript 100.00%

spotify-badge's Introduction

Spotify is playing now in your README.md

If you want to share your love of music with the world you are in right place. You can share your currently playing track from your Spotify with just an image.

Features

๐ŸŽธ playing now - current state of track with real-time progress bar
๐ŸŽฌ ended state โ€“ when track is ended badge transitions to this state
โธ paused state - when current track is paused in player
๐Ÿ“ญ idle state โ€“ not playing

Deploy with Vercel

How to use

Create an Spotify application for authentication

  • Go to Spotify Developer Dashboard and log in with your Spotify account
  • Click Create An App
  • Fill in the name and description of new app and click Create.
  • Click Show Client Secret.
  • Copy Client ID and Client Secret we will need it a bit later.

Deploy an application to Vercel

  • Open this link for deploy app to Vercel
  • Click Continue on Clone Git Repository screen
  • Choose where you want to save code on Create Git Repository and Vercel will fork this repo automatically
  • Click Continue on Import Project screen
  • Put Client ID to SPOTIFY_CLIENT_ID and Client Secret to SPOTIFY_CLIENT_SECRET and put just - to SPOTIFY_REFRESH_TOKEN.
  • If you plan to use API specify API_CORS_HOST as host from which you plan to call the API endpoint. Read more
  • Click Deploy

Get Refresh Token

  • When application is deployed go to Dashboard
  • Copy your domain with prod label of your application
  • Go back to Spotify Developer Dashboard
  • Open application
  • Click to Edit Settings
  • Add path /api/auth to deployment domain. It should looks like this https://spotify-badge-c74hazo6k-akellbl4.vercel.app/api/auth. Screenshot
  • Put the url Redirect URI and click Add
  • Save changes with click to Save in end of the form
  • Open new tab on the browser and go to url which you put in Redirect URI. The url should looks like this https://spotify-badge-c74hazo6k-akellbl4.vercel.app.akellbl4.vercel.app/api/auth
  • Copy Refresh token and put to the application settings on Vercel
  • Go to Deployments page and redeploy the last deployment of your application on Vercel
  • Everything is done!

You can copy this snippet and change domain in the url to domain of your application and post it wherever you would like

<img
	src="https://spotify-playing-now-readme.vercel.app/api/now-playing.svg"
	width="540"
	height="52"
/>

API

To make API available you need to specify API_CORS_HOST after you deployed the app.

  • Open created project on Vercel and go to Settings.
  • Open tab Environment Variables
  • Create variable with name API_CORS_HOST and put site address from which you plan make requests for example https://example.com (the variable will be set to Access-Control-Allow-Origin header. More about the header)

GET /api/now-playing

Response:

When something is playing

type Response =
	/** When a track is playing */
	| {
			progress: number | null
			duration: number
			track: string
			artist: string
			isPlaying: boolean
			coverUrl: string
			url: string
	  }

	/** When nothing is playing */
	| {
			isPlaying: false
	  }

Development

  • Copy .env.example to .env and add values to env variables
  • Run yarn for dependencies installation
  • Run yarn dev for starting development server

spotify-badge's People

Contributors

akellbl4 avatar marsidev avatar dependabot[bot] avatar noahsark769 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.