iOS Shortcut · Cloudflare Pages

Apple Music YouTube

A tiny, single-user API that takes the song you're playing in Apple Music and drops it into a fixed YouTube playlist.

How it works

  1. An iOS Shortcut reads the currently playing track (title + artist).
  2. It POSTs to this site's API with a shared secret.
  3. The API searches YouTube for the best matching video.
  4. It adds that video to the target playlist (skipping duplicates).
  5. It returns compact JSON the Shortcut shows as a notification.

API

POST/api/add-song

Header: Authorization: Bearer <SHORTCUT_TOKEN>

Request body:

{ "title": "Blinding Lights", "artist": "The Weeknd" }

Success response:

{
  "ok": true,
  "videoId": "abc123",
  "videoTitle": "The Weeknd - Blinding Lights",
  "playlistItemId": "xyz789",
  "alreadyInPlaylist": false
}

Failures return { "ok": false, "error": "..." } with a non-2xx status.

One-time owner setup

The playlist owner mints a YouTube refresh token once via /api/oauth/start, then stores these as Cloudflare Pages secrets:

Until those are set, the API responds with a configuration error.