{
  "openapi": "3.1.0",
  "info": {
    "title": "eleMusic.fm Public Streaming API",
    "version": "1.1.0",
    "summary": "Zero-login REST API to stream 1,300+ original AI songs and 24/7 genre radio stations into custom apps, OBS overlays, Twitch/Discord bots, and venues.",
    "description": "The **eleMusic.fm Public Streaming API** lets developers, livestreamers, and venue operators stream featured vocal and instrumental tracks (*Spectrum, Vol. 1*) and 8 continuous 24/7 instrumental genre radio stations for free without an account or API key. Public GET endpoints support cross-origin requests.\n\n### Required Attribution & Acceptable Use\n1. **Live Streaming Only:** Stream directly from presigned URLs returned by this API (valid up to 6 hours). The Terms cover eligible live background playback. Exclude the music from recordings, clips, VODs, and downloadable files. Bulk ripping, dataset harvesting, mirroring raw audio archives, and training/evaluating ML models are strictly prohibited.\n2. **Visible or Chat Attribution:** Custom apps, widgets, and bots must display a visible link or chat credit to `https://elemusic.fm` and link to the [model and provenance notices](https://elemusic.fm/notices), including *Powered by Stability AI*.\n3. **Custom music:** For generation tools and current pricing, visit `https://create.elemusiclabs.com` or connect to the Create MCP endpoint at `https://studio.elemusiclabs.com/mcp`.",
    "termsOfService": "https://elemusic.fm/terms",
    "contact": {
      "name": "eleMusic Inc. Developer Support",
      "url": "https://elemusic.fm/developers",
      "email": "hello@elemusic.fm"
    },
    "license": {
      "name": "eleMusic.fm Public Streaming & API Terms",
      "url": "https://elemusic.fm/terms"
    }
  },
  "externalDocs": {
    "description": "Developer Quickstart, OBS Overlay, Twitch Nightbot Setup & MCP Generation Guide",
    "url": "https://elemusic.fm/developers"
  },
  "servers": [
    {
      "url": "https://elemusic.fm/api",
      "description": "Primary Edge API Gateway (recommended for browsers, OBS & apps)"
    },
    {
      "url": "https://auth.elemusic.fm",
      "description": "Direct Streaming Gateway Origin"
    }
  ],
  "tags": [
    {
      "name": "24/7 Genre Radio",
      "description": "Browse 8 continuous instrumental genre stations (1,299 mastered tracks) and fetch zero-egress R2 streaming queues."
    },
    {
      "name": "Originals Catalog",
      "description": "Browse original vocal and instrumental showcase tracks (*Spectrum, Vol. 1*) with lyrics, BPM, key, ISRC, and provenance credits."
    },
    {
      "name": "Streamer & Chat Tools",
      "description": "Zero-code plaintext and JSON endpoints for Twitch/YouTube chat bots (Nightbot, StreamElements, Fossabot) and OBS overlays."
    },
    {
      "name": "System",
      "description": "Service health and readiness."
    }
  ],
  "paths": {
    "/v1/stations": {
      "get": {
        "tags": [
          "24/7 Genre Radio"
        ],
        "operationId": "listStations",
        "summary": "List all 8 live 24/7 instrumental genre radio stations",
        "description": "Returns station slugs, curated descriptions, track counts, and deep-links to generate similar styles in eleMusic Create.",
        "responses": {
          "200": {
            "description": "Array of curated 24/7 genre stations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Station"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/stations/{slug}/queue": {
      "get": {
        "tags": [
          "24/7 Genre Radio"
        ],
        "operationId": "getStationQueue",
        "summary": "Fetch a shuffled station queue with time-limited MP3 URLs",
        "description": "Returns up to 50 mastered tracks for the requested station, each carrying a direct byte-range-enabled (`206 Partial Content`) Cloudflare R2 MP3 stream URL and Unix expiration timestamp (`url_expires_at`). URLs can be reused until that timestamp. Rate limit: 240 requests per 15 minutes per IP.",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Station slug (`soft-piano`, `light-jazz`, `ambient`, `calm`, `acoustic-guitar`, `classical`, `tropical`, `elevator`).",
            "schema": {
              "type": "string",
              "enum": [
                "soft-piano",
                "light-jazz",
                "ambient",
                "calm",
                "acoustic-guitar",
                "classical",
                "tropical",
                "elevator"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Number of tracks to return (1..50, default 25).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 25
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Position in the rotation. Advance by the number of tracks actually returned.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2147483647,
              "default": 0
            }
          },
          {
            "name": "day",
            "in": "query",
            "description": "UTC rotation date. Defaults to the current UTC date.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "device",
            "in": "query",
            "required": false,
            "description": "Optional client/session seed string used to select one of the active shuffle pools.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Station queue payload with presigned MP3 stream URLs and attribution block.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StationQueueResponse"
                }
              }
            }
          },
          "503": {
            "description": "Station temporarily unavailable."
          },
          "404": {
            "description": "Unknown station slug."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/samples": {
      "get": {
        "tags": [
          "24/7 Genre Radio"
        ],
        "operationId": "listSamples",
        "summary": "List approved standalone samples, when available",
        "responses": {
          "200": {
            "description": "Curated station samples. The list can be empty. Use a station queue for full playback.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "station": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "url": {
                        "type": "string",
                        "format": "uri"
                      },
                      "url_expires_at": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/tracks/url": {
      "get": {
        "tags": [
          "24/7 Genre Radio"
        ],
        "operationId": "getStationTrackUrl",
        "summary": "Renew playback for a track in a published radio station",
        "description": "Pass the complete track_id from a queue. This endpoint shares the station queue rate limit.",
        "parameters": [
          {
            "name": "key",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A time-limited URL and its expiration in Unix seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "track_id",
                    "url",
                    "url_expires_at"
                  ],
                  "properties": {
                    "track_id": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "url_expires_at": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid track ID."
          },
          "404": {
            "description": "Track is outside the published rotation."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Radio catalog temporarily unavailable."
          }
        }
      }
    },
    "/v1/originals": {
      "get": {
        "tags": [
          "Originals Catalog"
        ],
        "operationId": "listOriginals",
        "summary": "List all featured Original albums and tracks",
        "description": "Returns track metadata, lyrics, credits and Create links. Revalidate the metadata response with If-None-Match.",
        "parameters": [
          {
            "name": "include_urls",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "true"
              ]
            },
            "description": "Include each track's stream_url and stream_expires_at in Unix seconds."
          }
        ],
        "responses": {
          "200": {
            "description": "Catalog of featured Original albums and tracks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginalsCatalogResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/originals/manifest": {
      "get": {
        "tags": [
          "Originals Catalog"
        ],
        "operationId": "getOriginalsManifest",
        "summary": "Get the Originals catalog with time-limited playback URLs",
        "description": "Alias of /v1/originals?include_urls=1. Shares the Originals URL rate limit.",
        "responses": {
          "200": {
            "description": "Originals with stream_url and stream_expires_at.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginalsCatalogResponse"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Originals playback temporarily unavailable."
          }
        }
      }
    },
    "/v1/originals/{slug}": {
      "get": {
        "tags": [
          "Originals Catalog"
        ],
        "operationId": "getOriginalTrack",
        "summary": "Get full metadata and lyrics for a single Original track",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Track slug (for example `01-midnight-on-the-coastline`).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Track metadata and lyrics.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginalTrack"
                }
              }
            }
          },
          "404": {
            "description": "Track slug not found."
          }
        }
      }
    },
    "/v1/originals/{slug}/url": {
      "get": {
        "tags": [
          "Originals Catalog"
        ],
        "operationId": "getOriginalStreamUrl",
        "summary": "Resolve a presigned 320 kbps MP3 stream URL for an Original track",
        "description": "Returns a pooled presigned `audio/mpeg` stream URL supporting HTTP `Range` (`206 Partial Content`). Rate limit: 120 requests per 15 minutes per IP.",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Track slug (for example `01-midnight-on-the-coastline`).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Signed stream URL and Create remix link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginalStreamUrlResponse"
                }
              }
            }
          },
          "404": {
            "description": "Track slug not found."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Originals playback temporarily unavailable."
          }
        }
      }
    },
    "/v1/chat/now-playing": {
      "get": {
        "tags": [
          "Streamer & Chat Tools"
        ],
        "operationId": "getChatNowPlaying",
        "summary": "Plaintext or JSON `!song` / `!music` responder for Twitch, YouTube & Discord bots",
        "description": "Designed for zero-code chat bot `$(urlfetch ...)` commands in Nightbot, StreamElements, Fossabot, Moobot, and custom Discord bots. Returns `text/plain` by default. Supply the station or Original your player selected. The endpoint does not read a listener session.",
        "parameters": [
          {
            "name": "station",
            "in": "query",
            "required": false,
            "description": "Station slug currently playing on stream (for example `light-jazz` or `soft-piano`).",
            "schema": {
              "type": "string",
              "default": "light-jazz"
            }
          },
          {
            "name": "track",
            "in": "query",
            "required": false,
            "description": "Optional Featured Original slug instead of a radio station (for example `01-midnight-on-the-coastline`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "Response format: `text` (default for Nightbot/StreamElements) or `json`.",
            "schema": {
              "type": "string",
              "enum": [
                "text",
                "json"
              ],
              "default": "text"
            }
          },
          {
            "name": "ref",
            "in": "query",
            "required": false,
            "description": "Optional channel or app identifier (`[a-zA-Z0-9_-]{1,32}`) attached to referral links.",
            "schema": {
              "type": "string",
              "maxLength": 32
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Formatted chat line or structured JSON object.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "Streaming Light Jazz Radio on eleMusic.fm | Listen free: https://elemusic.fm/stations/light-jazz | Create custom songs: https://create.elemusiclabs.com/?utm_source=chat-bot&station=light-jazz"
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatNowPlayingResponse"
                }
              }
            }
          },
          "400": {
            "description": "Unsupported format."
          },
          "404": {
            "description": "Unknown station or track."
          }
        }
      }
    },
    "/health": {
      "get": {
        "tags": [
          "System"
        ],
        "operationId": "getHealth",
        "summary": "Gateway health check",
        "responses": {
          "200": {
            "description": "Service health status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "service": {
                      "type": "string"
                    },
                    "originals_tracks": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "RateLimited": {
        "description": "Too many requests. Wait for Retry-After before retrying.",
        "headers": {
          "Retry-After": {
            "description": "Delay in seconds.",
            "schema": {
              "type": "integer"
            }
          }
        }
      }
    },
    "schemas": {
      "Attribution": {
        "type": "object",
        "properties": {
          "required_text": {
            "type": "string"
          },
          "required_url": {
            "type": "string",
            "format": "uri"
          },
          "studio_create_url": {
            "type": "string",
            "format": "uri"
          },
          "mcp_generation_server": {
            "type": "string",
            "format": "uri"
          },
          "notices_url": {
            "type": "string",
            "format": "uri"
          },
          "terms_url": {
            "type": "string",
            "format": "uri"
          },
          "stability_notice": {
            "type": "string"
          },
          "ai_generated": {
            "type": "boolean"
          }
        }
      },
      "Station": {
        "type": "object",
        "required": [
          "slug",
          "name",
          "station_url",
          "studio_create_url"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "tagline": {
            "type": "string"
          },
          "hint": {
            "type": "string"
          },
          "blurb": {
            "type": "string"
          },
          "track_count": {
            "type": "integer"
          },
          "enabled": {
            "type": "boolean"
          },
          "engine": {
            "type": "string"
          },
          "content_kind": {
            "type": "string"
          },
          "station_url": {
            "type": "string",
            "format": "uri"
          },
          "studio_create_url": {
            "type": "string",
            "format": "uri"
          },
          "attribution_text": {
            "type": "string"
          }
        }
      },
      "StationQueueTrack": {
        "type": "object",
        "required": [
          "track_id",
          "url",
          "url_expires_at",
          "engine"
        ],
        "properties": {
          "track_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "style": {
            "type": "string"
          },
          "duration_s": {
            "type": "number"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "url_expires_at": {
            "type": "integer"
          },
          "ai_generated": {
            "type": "boolean"
          },
          "engine": {
            "type": "string"
          }
        }
      },
      "StationQueueResponse": {
        "type": "object",
        "required": [
          "station",
          "tracks",
          "attribution"
        ],
        "properties": {
          "station": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "offset": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          },
          "station_url": {
            "type": "string",
            "format": "uri"
          },
          "studio_create_url": {
            "type": "string",
            "format": "uri"
          },
          "attribution": {
            "$ref": "#/components/schemas/Attribution"
          },
          "tracks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StationQueueTrack"
            }
          }
        }
      },
      "OriginalTrack": {
        "type": "object",
        "required": [
          "slug",
          "title",
          "mp3_sha256",
          "studio_create_url"
        ],
        "properties": {
          "track_number": {
            "type": "integer"
          },
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "artist": {
            "type": "string"
          },
          "album_slug": {
            "type": "string"
          },
          "album_title": {
            "type": "string"
          },
          "genre": {
            "type": "string"
          },
          "vocal_type": {
            "type": "string"
          },
          "is_instrumental": {
            "type": "boolean"
          },
          "bpm": {
            "type": "integer"
          },
          "key": {
            "type": "string"
          },
          "duration_s": {
            "type": "number"
          },
          "integrated_lufs": {
            "type": "number"
          },
          "isrc": {
            "type": "string"
          },
          "engine_id": {
            "type": "string"
          },
          "engine_display": {
            "type": "string"
          },
          "provenance_badge": {
            "type": "string"
          },
          "lyrics": {
            "type": "string"
          },
          "cover_art_url": {
            "type": "string"
          },
          "mp3_sha256": {
            "type": "string"
          },
          "stream_url": {
            "type": "string",
            "format": "uri"
          },
          "stream_expires_at": {
            "type": "integer"
          },
          "studio_create_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "OriginalsCatalogResponse": {
        "type": "object",
        "required": [
          "albums",
          "tracks",
          "updated_at",
          "attribution"
        ],
        "properties": {
          "updated_at": {
            "type": "string"
          },
          "developer_docs": {
            "type": "string",
            "format": "uri"
          },
          "attribution": {
            "$ref": "#/components/schemas/Attribution"
          },
          "albums": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "tracks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OriginalTrack"
            }
          }
        }
      },
      "OriginalStreamUrlResponse": {
        "type": "object",
        "required": [
          "slug",
          "url",
          "url_expires_at",
          "mp3_sha256"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "expires_in": {
            "type": "integer"
          },
          "expires_at": {
            "type": "integer"
          },
          "mp3_sha256": {
            "type": "string"
          },
          "url_expires_at": {
            "type": "integer"
          },
          "studio_create_url": {
            "type": "string",
            "format": "uri"
          },
          "attribution": {
            "$ref": "#/components/schemas/Attribution"
          }
        }
      },
      "ChatNowPlayingResponse": {
        "type": "object",
        "required": [
          "kind",
          "slug",
          "message",
          "listen_url"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "station",
              "original"
            ]
          },
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "listen_url": {
            "type": "string",
            "format": "uri"
          },
          "studio_create_url": {
            "type": "string",
            "format": "uri"
          },
          "mcp_server_url": {
            "type": "string",
            "format": "uri"
          },
          "attribution": {
            "$ref": "#/components/schemas/Attribution"
          }
        }
      }
    }
  }
}
