🎵 Album Tracks
Track ordering and metadata within albums
Resource Overview
Album Tracks represent the many-to-many relationships between albums and tracks, managing track order within albums and providing metadata for the album-track associations. This pivot resource is essential for organizing track sequences in albums.
Base Endpoint
/album-tracks
Resource Type
album-tracks
User Scope
Album owner-restricted
Schema
Required Relationships
Relationship | Type | Related Resource | Description |
---|---|---|---|
album | BelongsTo | albums | Album to associate track with |
track | BelongsTo | tracks | Track to associate with album |
Optional Attributes
Field | Type | Validation | Description |
---|---|---|---|
order | integer | nullable, min:1, unique per album | Track display order within album |
Read-only Attributes
Field | Type | Description |
---|---|---|
id | string | Unique identifier |
track-id | integer | ID of the associated track |
track-title | string | Title of the associated track |
album-id | integer | ID of the associated album |
album-title | string | Title of the associated album |
Business Validations
- • Unique combination: Same track cannot be added twice to same album
- • Album ownership: Can only associate tracks with albums you own
- • Order uniqueness: Order position must be unique within the album
- • Read-only resource: Managed through Albums and Tracks resources
List Album Tracks
GET
/album-tracks
GET /album-tracks
Authorization: Bearer {token}
Accept: application/vnd.api+json
Query Parameters
Filtering
- •
filter[album]
- Filter by album ID - •
filter[track]
- Filter by track ID - •
filter[order]
- Filter by track order
Other Parameters
- •
include
- Include relationships - •
sort
- Sort by field - •
page[number]
- Page number - •
page[size]
- Results per page
Example Request
GET /album-tracks?include=album,track&filter[album]=1&sort=order
Success Response
200 OK
{
"data": [
{
"type": "album-tracks",
"id": "1",
"attributes": {
"order": 1,
"track-id": 15,
"track-title": "Electric Opening",
"album-id": 3,
"album-title": "Digital Dreams"
},
"relationships": {
"album": {
"data": { "type": "albums", "id": "3" }
},
"track": {
"data": { "type": "tracks", "id": "15" }
}
}
},
{
"type": "album-tracks",
"id": "2",
"attributes": {
"order": 2,
"track-id": 16,
"track-title": "Neon Nights",
"album-id": 3,
"album-title": "Digital Dreams"
},
"relationships": {
"album": {
"data": { "type": "albums", "id": "3" }
},
"track": {
"data": { "type": "tracks", "id": "16" }
}
}
}
],
"included": [
{
"type": "albums",
"id": "3",
"attributes": {
"title": "Digital Dreams",
"artwork": "https://storage.example.com/artwork/digital-dreams.jpg"
}
},
{
"type": "tracks",
"id": "15",
"attributes": {
"title": "Electric Opening",
"length": "00:03:42",
"is-explicit": false
}
},
{
"type": "tracks",
"id": "16",
"attributes": {
"title": "Neon Nights",
"length": "00:04:18",
"is-explicit": false
}
}
],
"meta": {
"page": {
"currentPage": 1,
"from": 1,
"lastPage": 1,
"perPage": 20,
"to": 2,
"total": 2
}
}
}
Get Album Track
GET
/album-tracks/{id}
GET /album-tracks/1
Authorization: Bearer {token}
Accept: application/vnd.api+json
Success Response
200 OK
{
"data": {
"type": "album-tracks",
"id": "1",
"attributes": {
"order": 1,
"track-id": 15,
"track-title": "Electric Opening",
"album-id": 3,
"album-title": "Digital Dreams"
},
"relationships": {
"album": {
"data": { "type": "albums", "id": "3" }
},
"track": {
"data": { "type": "tracks", "id": "15" }
}
}
}
}
Key Features
🎯 Track Ordering
- • Manage track sequence
- • Unique order per album
- • Sequential organization
- • Automatic sorting
🔍 Read-Only Access
- • Query associations
- • Filter by album/track
- • Include relationships
- • User-scoped results
🔗 Relationships
- • Links albums to tracks
- • Maintains ordering
- • Provides metadata
- • Supports inclusion