Below are examples of requests and responses for each of the APIs defined in your Django project. I'll assume your API is hosted at http://localhost:8000/
.
GET http://localhost:8000/song/
[
{
"id": 1,
"name": "Imagine",
"author": "John Lennon",
"album": "example album",
"duration": 183,
"lyrics": "Imagine all the people...",
"topics": "Peace, Unity, Hope",
"mp3_url": "http://example.com/song1",
"cover_url": "http://example.com/images/imagine_cover.jpg"
},
{
"id": 2,
"name": "Bohemian Rhapsody",
"author": "Queen",
"album": "example album",
"duration": 354,
"lyrics": "Is this the real life? Is this just fantasy?",
"topics": "Drama, Emotion, Storytelling",
"mp3_url": "http://example.com/song2",
"cover_url": "http://example.com/images/bohemian_rhapsody_cover.jpg"
}
]
{
"name": "Hey Jude",
"author": "The Beatles",
"album": "example album",
"duration": 430,
"lyrics": "Hey Jude, don't make it bad...",
"topics": "Encouragement, Love, Friendship",
"mp3_url": "http://example.com/heyjude",
"cover_url": "http://example.com/images/hey_jude_cover.jpg"
}
{
"id": 3,
"name": "Hey Jude",
"author": "The Beatles",
"album": "example album",
"duration": 430,
"lyrics": "Hey Jude, don't make it bad...",
"topics": "Encouragement, Love, Friendship",
"mp3_url": "http://example.com/heyjude",
"cover_url": "http://example.com/images/hey_jude_cover.jpg"
}
GET http://localhost:8000/song/1/
{
"id": 1,
"name": "Imagine",
"author": "John Lennon",
"album": "example album",
"duration": 183,
"lyrics": "Imagine all the people...",
"topics": "Peace, Humanity, Hope",
"mp3_url": "http://example.com/song1",
"cover_url": "http://example.com/song1-cover.jpg"
}
{
"name": "Imagine",
"author": "John Lennon",
"album": "example album",
"duration": 200,
"lyrics": "Imagine all the people living life in peace...",
"topics": "Peace, Humanity, Hope",
"mp3_url": "http://example.com/song1-updated",
"cover_url": "http://example.com/song1-cover-updated.jpg"
}
{
"id": 1,
"name": "Imagine",
"author": "John Lennon",
"album": "example album",
"duration": 200,
"lyrics": "Imagine all the people living life in peace...",
"topics": "Peace, Humanity, Hope",
"mp3_url": "http://example.com/song1-updated",
"cover_url": "http://example.com/song1-cover-updated.jpg"
}
DELETE http://localhost:8000/song/1/
{
"detail": "Song deleted successfully."
}
search=keyword limit=X ai=True
GET http://localhost:8000/song/search/?search=Imagine&limit=20
[
{
"id": 1,
"name": "Imagine",
"author": "John Lennon",
"album": "example album",
"duration": 183,
"lyrics": "Imagine all the people...",
"topics": "Peace, Humanity, Hope",
"mp3_url": "http://example.com/song1",
"cover_url": "http://example.com/song1-cover.jpg"
}
]
GET http://localhost:8000/favlist/
[
{
"id": 1,
"name": "Chill Vibes",
"songs": [1, 2]
}
]
{
"name": "Workout Jams",
"songs": [2, 3]
}
{
"id": 2,
"name": "Workout Jams",
"songs": [2, 3]
}
GET http://localhost:8000/favlist/1/
{
"id": 1,
"name": "Chill Vibes",
"songs": [1, 2],
"songs_detail": [
{
"id": 1,
"name": "Imagine",
"author": "John Lennon",
"album": "example album",
"duration": 183,
"lyrics": "Imagine all the people...",
"topics": "Peace, Unity, Hope",
"mp3_url": "http://example.com/song1",
"cover_url": "http://example.com/images/imagine_cover.jpg"
},
{
"id": 2,
"name": "Bohemian Rhapsody",
"author": "Queen",
"album": "example album",
"duration": 354,
"lyrics": "Is this the real life? Is this just fantasy?",
"topics": "Drama, Emotion, Storytelling",
"mp3_url": "http://example.com/song2",
"cover_url": "http://example.com/images/bohemian_rhapsody_cover.jpg"
}
]
}
{
"name": "Evening Relaxation",
"songs": [1]
}
{
"id": 1,
"name": "Evening Relaxation",
"songs": [1]
}
partially modify:
{
"name": "PATCH",
}
{
"id": 1,
"name": "PATCH",
"songs": [1]
}
{
"songs": [1, 2],
}
{
"id": 1,
"name": "PATCH",
"songs": [1, 2]
}
DELETE http://localhost:8000/favlist/1/
{
"detail": "Favlist deleted successfully."
}
GET http://localhost:8000/userfav/
Authorization: Bearer <JWT_TOKEN>
[
{
"user": 1,
"favlists": [1, 2]
}
]
{
"favlists": [1]
}
{
"user": 1,
"favlists": [1]
}
partially modify:
{
"favlists": [2]
}
{
"user": 1,
"favlists": [2]
}
DELETE http://localhost:8000/userfav/1/
Authorization: Bearer <JWT_TOKEN>
{
"detail": "User favorites deleted successfully."
}
GET http://localhost:8000/generate-songs/1/
[
{
"id": 1,
"name": "The Rhyme Chronicles",
"author": "SunoAI",
"album": "SunoAI Generation",
"duration": 189,
"lyrics": "[Verse 1]\nGot the city lights flickerin..",
"topics": "",
"mp3_url": "https://cdn1.suno.ai/ee0717ad-aded-4008-a30c-4f43bbcb3fc3.mp3",
"cover_url": "https://cdn2.suno.ai/image_ee0717ad-aded-4008-a30c-4f43bbcb3fc3.jpeg"
},
{
"id": 2,
"name": "The Rhyme Chronicles",
"author": "SunoAI",
"album": "SunoAI Generation",
"duration": 97,
"lyrics": "[Verse 1]\nGot the city lights flickerin..",
"topics": "",
"mp3_url": "https://cdn1.suno.ai/7d47a123-b4e0-436d-8b01-6e9acbc5f1bf.mp3",
"cover_url": "https://cdn2.suno.ai/image_7d47a123-b4e0-436d-8b01-6e9acbc5f1bf.jpeg"
}
]
curl -X POST http://localhost:8000/userfav/ ^
-H "Content-Type: application/json" ^
-d "{\"favlists\": [2, 3]}" ^
--user "heaplax"
curl -X PUT http://localhost:8000/userfav/ ^
-H "Content-Type: application/json" ^
-d "{\"favlists\": [2]}" ^
--user "heaplax"