iOS Shortcut · Cloudflare Pages

Apple Music → YouTube

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

How it works

  1. An iOS Shortcut reads the currently playing track (title + artist), or takes text you type or share.
  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.
  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,
  "message": "Added: The Weeknd - Blinding Lights",
  "videoId": "abc123",
  "videoTitle": "The Weeknd - Blinding Lights",
  "playlistItemId": "xyz789",
  "alreadyInPlaylist": false
}

POST/api/add-text

Same header. Send whatever was typed or shared: an Apple Music song link, a YouTube link, Shazam share text, or a title and artist.

{ "text": "https://music.apple.com/us/song/blinding-lights/1488408568" }

Every response includes message, a ready-to-show Added: ... or Failed: ... line. Failures return { "ok": false, "error": "...", "message": "..." } 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.