📖 API Documentation
This API provides access to Spotify song data and can generate SVGs for README files and other applications.
GET Current/Recent Song Data
/api/song
Description: Returns the currently playing song or the most recently played song from Spotify.
Response Format:
{
"isPlaying": boolean,
"title": string,
"artist": string,
"album": string,
"albumImageUrl": string,
"songUrl": string,
"previewUrl": string | null,
"duration": number,
"progress": number | null,
"playedAt": string (if not currently playing)
}
GET Song SVG for README
/api/svg
Description: Returns an SVG image showing the current/recent song data. Perfect for embedding in README files!
Content-Type: image/svg+xml
Features:
- Dark theme matching Spotify's design
- Shows playing status with visual indicators
- Progress bar for currently playing songs
- Responsive 400x120px size
- Automatic text truncation for long titles
GET Health Check
/health
Description: Basic health check endpoint to verify the API is running.
💻 Usage Examples
📄 README.md Integration

[](https://open.spotify.com/user/your-username)
🌐 HTML Integration
<!-- Embed as an image -->
<img src="YOUR_DOMAIN/api/svg" alt="Current Spotify Song" />
<!-- Or embed the SVG directly -->
<object data="YOUR_DOMAIN/api/svg" type="image/svg+xml"></object>
📊 JavaScript/Fetch (JSON Data)
fetch('YOUR_DOMAIN/api/song')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
🔧 cURL
# Get JSON data
curl -X GET YOUR_DOMAIN/api/song
# Get SVG
curl -X GET YOUR_DOMAIN/api/svg
🐍 Python
import requests
# Get JSON data
response = requests.get('YOUR_DOMAIN/api/song')
data = response.json()
print(data)
# Get SVG content
svg_response = requests.get('YOUR_DOMAIN/api/svg')
svg_content = svg_response.text
print(svg_content)
⚙️ Setup & Configuration
This API requires Spotify API credentials to function. Make sure you have:
- Spotify Client ID
- Spotify Client Secret
- Spotify Refresh Token
The API automatically handles token refresh and caching for optimal performance.