Spotify API

Dokumentasi resmi untuk endpoint Spotify Downloader. Endpoint ini punya 2 mode: search (query teks) memakai spotifySearch.js dengan Spotify partner API + TOTP auth (no env vars needed, no DDG/Bing), dan download (Spotify URL) memakai spotmate.js untuk konversi audio MP3. Thumbnail, preview, dan audio URL di-rewrite ke domain API ini.

Wajib API Key Cost 5 per request berhasil Proxy gratis tanpa apikey Refund otomatis kalau gagal Engine: spotifySearch.js + spotmate.js
Domain aktif
Dashboardhttps://api.chioriya.my.id
Search EndpointGET /api/spotify?q=...&apikey=...
Download EndpointGET /api/spotify?url=...&apikey=...
Thumb ProxyGET /api/spotify/thumb?url=<id>
Audio ProxyGET /api/spotify/audio?t=<token>

Quick Start

GET https://api.chioriya.my.id/api/spotify?q=Enchanted&apikey=YOUR_APIKEY
Endpoint /api/spotify wajib memakai API key panel. Cost 5 limit per request berhasil (refund otomatis kalau gagal). Ada 2 mode:

Search (input = query teks): return allSongs (5 lagu) dengan previewUrl 30-detik. pickedSong dan audioUrl = null.
Download (input = Spotify URL): return pickedSong + audioUrl (full MP3) + allSongs.

Contoh response Search (query)

{
  "status": true,
  "ok": true,
  "source": "spotify",
  "traceId": "spotify_search_abc123",
  "input": "Enchanted",
  "inputType": "query",
  "auth": "apikey",
  "cost": 5,
  "contentType": "search",
  "pickedSong": null,
  "allSongs": [
    {
      "title": "Enchanted",
      "artist": "Taylor Swift",
      "url": "https://open.spotify.com/track/1nyySeUvIxeIydsDL4G80X",
      "thumbnail": "/api/spotify/thumb?url=ab67616d0000b2730ac2865a6b8b6ffecf85ce7d",
      "originalThumbnail": "https://i.scdn.co/image/ab67616d0000b2730ac2865a6b8b6ffecf85ce7d",
      "duration": 353,
      "spotifyId": "1nyySeUvIxeIydsDL4G80X",
      "previewUrl": "/api/spotify/audio?t=aHR0cHM6...",
      "originalPreviewUrl": "https://p.scdn.co/mp3-preview/abc123..."
    },
    { "title": "Enchanted (Taylor's Version)", ... },
    ...total 5 songs
  ],
  "audioUrl": null,
  "audioType": null,
  "audioError": null
}

Contoh response Download (URL)

{
  "status": true,
  "ok": true,
  "source": "spotify",
  "traceId": "spotify_search_def456",
  "input": "https://open.spotify.com/track/1nyySeUvIxeIydsDL4G80X",
  "inputType": "url",
  "auth": "apikey",
  "cost": 5,
  "contentType": "track",
  "pickedSong": {
    "title": "Enchanted",
    "artist": "Taylor Swift",
    "url": "https://open.spotify.com/track/1nyySeUvIxeIydsDL4G80X",
    "thumbnail": "/api/spotify/thumb?url=ab67616d0000b2730ac2865a6b8b6ffecf85ce7d",
    "originalThumbnail": "https://i.scdn.co/image/ab67616d0000b2730ac2865a6b8b6ffecf85ce7d",
    "duration": 353,
    "spotifyId": "1nyySeUvIxeIydsDL4G80X"
  },
  "allSongs": [],
  "audioUrl": "/api/spotify/audio?t=aHR0cHM6...",
  "originalAudioUrl": "https://rapid.dlapi.app/download/tracks/...",
  "audioType": "instant",
  "audioError": null
}

Endpoint Spotify

SearchQuery teks → 5 lagu + preview URL.GET /api/spotify?q=...
DownloadSpotify URL → pickedSong + audioUrl MP3.GET /api/spotify?url=...
Thumb ProxyStream thumbnail i.scdn.co. Gratis.GET /api/spotify/thumb
Audio ProxyStream audio/preview MP3. Gratis.GET /api/spotify/audio

Parameter Main Endpoint

ParamDefaultKeterangan
apikey / header x-api-key / BearerwajibAPI key panel bot. Cost 5 limit per request berhasil. Refund otomatis kalau gagal.
q / queryโ€”Query pencarian untuk mode search. Contoh: Enchanted, Another Love. Return 5 lagu dengan preview URL. pickedSong = null.
urlโ€”Spotify URL untuk mode download. Contoh: https://open.spotify.com/track/xxx. Mendukung track, album, playlist. Return pickedSong + audioUrl.
API otomatis deteksi mode: kalau input diawali http:// atau https:// → mode download. Selain itu → mode search.

Parameter Proxy Endpoints (GRATIS, gak butuh apikey)

EndpointParamKeterangan
/api/spotify/thumburlImage ID dari i.scdn.co (contoh: ab67616d0000b2730b04da4f224b51ff86e0a481). Bisa juga full URL.
/api/spotify/audiotBase64url token (dari field audioUrl atau previewUrl di response). Stateless, selalu works.

Cara kirim API key (main endpoint)

Proxy endpoints (/api/spotify/thumb dan /api/spotify/audio) gak butuh apikey dan gak ngurangin limit. Buka/download URL dari response JSON sepuasnya.

URL Proxy Rewriting

Thumbnail, preview, dan audio URL di response sudah di-rewrite ke domain API ini. Proxy endpoints gak butuh apikey dan gak ngurangin limit.

Host yang di-allow untuk proxy

Thumb: i.scdn.co
Audio: rapid.dlapi.app, dlapi.app, audio-ak-spotify-com.akamaized.net,
       audio-fa.scdn.co, audio-gm-off.scdn.co, audio-off.scdn.co,
       audio-mp3-fa.scdn.co, audio-fa.spotifycdn.com, p.scdn.co
Host lain diluar list di atas akan ditolak dengan 403. Audio proxy pakai base64url token (stateless) jadi selalu works di serverless.

Struktur Response

FieldTipeKeterangan
status / okbooleantrue kalau request sukses.
sourcestringSelalu spotify.
traceIdstringID trace untuk pelacakan error.
input / inputTypestringInput asli dan tipe (query atau url).
auth / coststring/numberSelalu apikey dan cost yang dipotong (5).
contentTypestringsearch (mode search), track/album/playlist (mode download).
pickedSongobject|nullnull di mode search. Di mode download: lagu terpilih dengan title, artist, url, thumbnail (proxy), originalThumbnail, duration, spotifyId.
allSongsarrayMode search: 5 lagu dengan previewUrl (30-detik). Mode download: list lagu lain (kosong untuk single track).
audioUrlstring|nullnull di mode search. Di mode download: full MP3 URL yang sudah di-rewrite ke /api/spotify/audio?t=....
originalAudioUrlstring|nullAudio URL asli dari rapid.dlapi.app sebelum di-rewrite. Hanya di mode download.
audioTypestring|nullinstant atau async. Hanya di mode download.
audioErrorstring|nullPesan error kalau konversi audio gagal.
remainingnumberSisa limit panel setelah request.
Search → Download flow: Panggil /api/spotify?q=... untuk cari lagu. Pilih lagu dari allSongs, lalu panggil /api/spotify?url=song_url untuk download full MP3. Cost 5 limit per request.

Examples

1. Search lagu (query → list 5 lagu + preview)

fetch("/api/spotify?q=Enchanted&apikey=YOUR_APIKEY")
  .then(res => res.json())
  .then(data => {
    console.log("Found", data.allSongs.length, "songs");
    data.allSongs.forEach((song, i) => {
      console.log(`${i+1}. ${song.title} - ${song.artist}`);
      console.log("   URL:", song.url);
      console.log("   Preview:", song.previewUrl);
      console.log("   Thumbnail:", song.thumbnail);
    });
  });

2. Search + Download (query → pilih lagu → download MP3)

// Step 1: Search lagu
const searchRes = await fetch("/api/spotify?q=Enchanted&apikey=YOUR_APIKEY");
const searchData = await searchRes.json();

// Step 2: Pilih lagu pertama dari allSongs
const song = searchData.allSongs[0];
console.log("Downloading:", song.title, "-", song.artist);

// Step 3: Download full MP3 pakai URL lagu yang dipilih
const dlRes = await fetch("/api/spotify?url=" + encodeURIComponent(song.url) + "&apikey=YOUR_APIKEY");
const dlData = await dlRes.json();

// Step 4: Audio URL siap untuk stream/download (gratis, gak butuh apikey)
console.log("Audio URL:", dlData.audioUrl);
console.log("Picked:", dlData.pickedSong.title, "-", dlData.pickedSong.artist);

// Play di browser
const audio = new Audio(dlData.audioUrl);
audio.play();

3. Download langsung dari Spotify URL

fetch("/api/spotify?url=https%3A%2F%2Fopen.spotify.com%2Ftrack%2F1nyySeUvIxeIydsDL4G80X&apikey=YOUR_APIKEY")
  .then(res => res.json())
  .then(data => {
    console.log(data.pickedSong.title, data.pickedSong.artist);
    console.log("Audio URL:", data.audioUrl);
  });

4. POST dengan body JSON

const res = await fetch("/api/spotify", {
  method: "POST",
  headers: { "Content-Type": "application/json", "x-api-key": "YOUR_APIKEY" },
  body: JSON.stringify({ q: "Enchanted" })
});
const data = await res.json();
console.log(data.allSongs);

5. Stream preview 30-detik dari search (gratis)

const audio = document.querySelector("audio");
audio.src = data.allSongs[0].previewUrl; // Sudah /api/spotify/audio?t=...
audio.play();

6. Tampilkan thumbnail dari search (gratis)

const img = document.querySelector("img");
img.src = data.allSongs[0].thumbnail; // Sudah /api/spotify/thumb?url=...

7. Node.js (axios) — search + download + simpan file

const axios = require("axios");
const fs = require("fs");

async function searchAndDownload(query, apiKey, outputFile) {
  // Step 1: Search
  const searchRes = await axios.get("https://api.chioriya.my.id/api/spotify", {
    params: { q: query, apikey: apiKey },
    timeout: 30000
  });
  if (!searchRes.data.status) throw new Error("Search gagal");
  const song = searchRes.data.allSongs[0];
  console.log("Found:", song.title, "-", song.artist);

  // Step 2: Download via URL
  const dlRes = await axios.get("https://api.chioriya.my.id/api/spotify", {
    params: { url: song.url, apikey: apiKey },
    timeout: 180000
  });
  if (!dlRes.data.audioUrl) throw new Error("Audio gagal: " + dlRes.data.audioError);

  // Step 3: Stream audio ke file (proxy gratis, gak butuh apikey)
  const audioRes = await axios.get(dlRes.data.audioUrl, {
    responseType: "stream",
    timeout: 120000
  });
  audioRes.data.pipe(fs.createWriteStream(outputFile));
  return dlRes.data.pickedSong;
}

searchAndDownload("Enchanted", "YOUR_APIKEY", "enchanted.mp3")
  .then(song => console.log("Saved:", song.title, "-", song.artist))
  .catch(console.error);

8. Baileys / Keila — search + download

case "spotify": {
  if (!text) return m.keila("Contoh: .spotify Enchanted");
  await m.react("๐ŸŽต");

  const axios = require("axios");

  // Step 1: Search
  const searchRes = await axios.get("https://api.chioriya.my.id/api/spotify", {
    params: { q: text, apikey: global.apikey || "YOUR_APIKEY" },
    timeout: 30000
  });
  if (!searchRes.data.status) return m.keila("Search gagal.");
  if (!searchRes.data.allSongs.length) return m.keila("Tidak ada hasil.");

  // Step 2: Download lagu pertama
  const song = searchRes.data.allSongs[0];
  const dlRes = await axios.get("https://api.chioriya.my.id/api/spotify", {
    params: { url: song.url, apikey: global.apikey || "YOUR_APIKEY" },
    timeout: 180000
  });
  if (!dlRes.data.audioUrl) return m.keila("Audio gagal: " + dlRes.data.audioError);

  // Step 3: Get audio buffer (proxy gratis)
  const audioRes = await axios.get(dlRes.data.audioUrl, {
    responseType: "arraybuffer",
    timeout: 120000
  });
  const buffer = Buffer.from(audioRes.data);

  let teks = `*Spotify Downloader*\n\n` +
    `Title: ${dlRes.data.pickedSong.title}\n` +
    `Artist: ${dlRes.data.pickedSong.artist}\n` +
    `Duration: ${dlRes.data.pickedSong.duration || "-"}s`;
  await m.keila(teks);

  await keila.sendMessage(m.chat, {
    audio: buffer,
    mimetype: "audio/mpeg",
    fileName: (dlRes.data.pickedSong.title || "audio") + ".mp3"
  }, { quoted: m });
}
break;

Catatan Penting