Skip to content

Instantly share code, notes, and snippets.

@TheArmagan
Last active April 2, 2021 16:14
Show Gist options
  • Save TheArmagan/e1f9aa324d4583d63893b54822d798bd to your computer and use it in GitHub Desktop.
Save TheArmagan/e1f9aa324d4583d63893b54822d798bd to your computer and use it in GitHub Desktop.
Armagan's Spotify Presence - Usage

Armagan's Spotify Presence

BASE URL: https://spotifypresence.armagan.rest/

EMBED API

Base URL: /embed

Click to see example images.

Embed Previews

NOTE: As default color theme is set to auto so its changes color theme of the embed based on system theme.

  • Light Theme
  • Dark Theme
  • Custom Theme 000000,ff0000

Embed Parameters

Click here to see usage of the embed parameters.
  • id: User id of the targeted user. (Example: 707309693449535599, Default: none)

  • theme: Theme of the embed. (Example: dark, Default: auto)

    • Options:
      • auto
      • light
      • dark
      • custom
  • theme-bg: Background color of the embed. Used when theme set to custom. (Example: 000000, Default: none)

  • theme-fg: Foreground color of the embed. Used when theme set to custom. (Example: ff0000, Default: none)

  • offline-message: Showing when target user is listening anything. (Default: "User is currently not listening to anything..")

REST API

Click to see example response.

GET /api/v1/:userId

// When playing..
{
  "ok": true,
  "data": {
    "trackId": "5QOhIyCkKcHzBSHLHZaF39",
    "trackName": "Memory Lane",
    "artistNames": [
      "AcesToAces"
    ],
    "albumName": "Memory Lane",
    "albumArtwork": "https://i.scdn.co/image/ab67616d0000b27330a7a450660b982127e9d7bc",
    "time": {
      "duration": 135019,
      "start": 1617375746144,
      "end": 1617375881163
    },
    "userId": "707309693449535599"
  }
}
// When not playing..
{
  "ok": false
}
Click to see example response.

GET /api/v1/all

{
  "312617004362366977": {
    "trackId": "5gcwy6zwclsjcLVK1mvfaj",
    "trackName": "NORTHFACE",
    "artistNames": [
      "$NOT"
    ],
    "albumName": "NORTHFACE",
    "albumArtwork": "https://i.scdn.co/image/ab67616d0000b27342c777fede6956e03798c0f1",
    "time": {
      "duration": 112759,
      "start": 1617376157825,
      "end": 1617376270584
    },
    "userId": "312617004362366977"
  },
  "707309693449535599": {
    "trackId": "2mlGPkAx4kwF8Df0GlScsC",
    "trackName": "Buttercup",
    "artistNames": [
      "Jack Stauber"
    ],
    "albumName": "Pop Food",
    "albumArtwork": "https://i.scdn.co/image/ab67616d0000b273affdacd1466cdde505ab97ee",
    "time": {
      "duration": 208026,
      "start": 1617376108525,
      "end": 1617376316551
    },
    "userId": "707309693449535599"
  }
}

SOCKET.IO API

Click here to see example script.

Example JavaScript Code

// Connect to Armagan's Spotify Presence socket.io server.
let socket = io("https://spotifypresence.armagan.rest/");

// Add listener for presence update events.
socket.on("update", (data)=>{
  // Same response as /api/v1/707309693449535599
  console.log(data)
});

// And subscribe to presence updates using user id.
socket.emit("subscribe", "707309693449535599");

// Also you can unsubscribe to events too. Like so:
// socket.emit("unsubscribe", "707309693449535599");

IMPORTANT

This api only works when you in this discord server. So basicly its reads you spotify status using discord's api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment