Git Product home page Git Product logo

spotify-worker's Introduction

Spotify Stats Web Worker

A tiny API to retrieve statistics from Spotify for a specific account. Designed to be deployed using Cloudflare Workers, and built using Miniflare to enable things like local development and testing.

Usage

Spotify and environment setup

Before starting up the repo, you will need to obtain authentication from Spotify to use your account. I have created a script to handle the difficult part of this process, which you can use by running:

npm run spotify:auth

This will give you a Refresh Token, which will then be used repeatedly to keep the worker authenticated to use Spotify data.

You will then need to save some secret values with Wrangler, so that the Web Worker can access them. You will need to run the following to save these values:

wrangler secret put SPOTIFY_CLIENT_ID
# Paste your Spotify Client ID when prompted

wrangler secret put SPOTIFY_CLIENT_SECRET
# Paste your Spotify Client Secret when prompted

wrangler secret put SPOTIFY_REFRESH_TOKEN
# Paste your Refresh Token when prompted

Once this is complete, you should be able to make successful calls to the Web Worker's endpoint.

Worker setup

  1. Clone the repo, and install dependencies using npm install
  2. Run npm run dev to start the local development server (with live reload!)
  3. You should now be able to make calls to the endpoints exposed (listed below), and get data back.

Other commands

# Start remote development server using wrangler
$ npm run dev:remote

# Run tests - these have not been implemented yet but will be!
$ npm test

# Run type checking
$ npm run types:check

# Deploy using wrangler
$ npm run deploy

Endpoints

  • /top Retrieves a list of top tracks for the Spotify account

spotify-worker's People

Contributors

josephshambrook avatar

Watchers

 avatar  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.