Add song lookup API: search a track and get its play history + metadata

New GET /api/v1/me/tracks/search finds songs by track or artist name;
GET /api/v1/me/tracks returns a song's aggregated metadata (album,
duration, mbid, etc. - most common non-null value per field) plus its
paginated scrobble history, identified by artist+track query params
since there's no normalized Track model.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
mattandClaude Sonnet 5 committed 2026-10-05 14:14:11 +01:00
1 parent 50e2360d14
commit d2f457a84d
6 files changed
+552 -2

No files matched your search

+260
View File
@@ -992,6 +992,167 @@
]
}
},
"/api/v1/me/tracks/search": {
"get": {
"parameters": [
{
"in": "query",
"name": "q",
"schema": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"required": true
},
{
"in": "query",
"name": "limit",
"schema": {
"type": "integer",
"default": 20,
"minimum": 1,
"maximum": 50
},
"required": false
}
],
"responses": {
"422": {
"$ref": "#/components/responses/UNPROCESSABLE_CONTENT"
},
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/TrackSearchResult"
}
}
}
}
},
"401": {
"description": "Not authenticated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"default": {
"$ref": "#/components/responses/DEFAULT_ERROR"
}
},
"summary": "Find a song by track or artist name",
"tags": [
"Tracks"
],
"security": [
{
"bearerAuth": []
}
]
}
},
"/api/v1/me/tracks": {
"get": {
"parameters": [
{
"in": "query",
"name": "page",
"schema": {
"type": "integer",
"default": 1,
"minimum": 1
},
"required": false
},
{
"in": "query",
"name": "limit",
"schema": {
"type": "integer",
"default": 50,
"minimum": 1,
"maximum": 200
},
"required": false
},
{
"in": "query",
"name": "artist",
"schema": {
"type": "string",
"minLength": 1,
"maxLength": 500
},
"required": true
},
{
"in": "query",
"name": "track",
"schema": {
"type": "string",
"minLength": 1,
"maxLength": 500
},
"required": true
}
],
"responses": {
"422": {
"$ref": "#/components/responses/UNPROCESSABLE_CONTENT"
},
"404": {
"description": "You've never scrobbled this song",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TrackDetail"
}
}
}
},
"401": {
"description": "Not authenticated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"default": {
"$ref": "#/components/responses/DEFAULT_ERROR"
}
},
"summary": "A song's play history and recorded metadata",
"tags": [
"Tracks"
],
"security": [
{
"bearerAuth": []
}
]
}
},
"/api/v1/imports/options": {
"get": {
"responses": {
@@ -3205,6 +3366,10 @@
"name": "Stats",
"description": "Your listening history and statistics"
},
{
"name": "Tracks",
"description": "Look up a specific song's history and metadata"
},
{
"name": "Imports",
"description": "Import listening history from a Last.fm export file, or straight from Last.fm. Imports run in the background; poll a job to follow its progress."
@@ -3662,6 +3827,101 @@
},
"additionalProperties": false
},
"TrackSearchResult": {
"type": "object",
"properties": {
"artist": {
"type": "string"
},
"track": {
"type": "string"
},
"playcount": {
"type": "integer"
}
},
"additionalProperties": false
},
"TrackMetadata": {
"type": "object",
"properties": {
"album": {
"type": [
"string",
"null"
]
},
"album_artist": {
"type": [
"string",
"null"
]
},
"track_number": {
"type": [
"integer",
"null"
]
},
"duration": {
"type": [
"integer",
"null"
]
},
"mbid": {
"type": [
"string",
"null"
]
},
"playcount": {
"type": "integer"
},
"first_played_at": {
"type": "string",
"format": "date-time"
},
"last_played_at": {
"type": "string",
"format": "date-time"
}
},
"additionalProperties": false
},
"TrackDetail": {
"type": "object",
"properties": {
"page": {
"type": "integer"
},
"per_page": {
"type": "integer"
},
"total": {
"type": "integer"
},
"total_pages": {
"type": "integer"
},
"artist": {
"type": "string"
},
"track": {
"type": "string"
},
"metadata": {
"$ref": "#/components/schemas/TrackMetadata"
},
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Scrobble"
}
}
},
"additionalProperties": false
},
"ImportOptions": {
"type": "object",
"properties": {