Skip to content

AditiS-03/MusicTrackerAPI

 
 

Repository files navigation

🎵Music Tracker API A simple Node.js + SQLite3 project to manage a list of songs using RESTful APIs. Optionally includes a basic frontend to interact with the API.

📁 Project Structure 📦 Music Tracker API ├── controllers/ │ └── songController.js ├── routes/ │ └── songRoutes.js ├── db.js ├── music.db ├── server.js ├── MusicAPI.html (optional frontend) └── README.md

📌 Features ✅ Create, Read songs using API ✅ Local database using SQLite ✅ Integrated with DB Browser for SQLite ✅ HTML frontend (optional) ✅ Fully local setup — no external APIs used

🚀 How to Run This Project

  1. 📥 Clone the Repository bash git clone https://github.com/your-username/music-tracker-api.git cd music-tracker-api

  2. 📦 Install Dependencies Make sure you have Node.js installed, then: bash npm install

  3. ✅ Start the Server bash node server.js The server will start at: http://localhost:5000

🧠 API Endpoints GET /api/songs Returns all songs in the database. Response: json

{ "id": 1, "title": "Test Song", "artist": "Tester", "genre": "Rock" }

POST /api/songs Adds a new song to the database. Request Body: json { "title": "Shape of You", "artist": "Ed Sheeran", "genre": "Pop" }

Response: json { "id": 2, "title": "Shape of You", "artist": "Ed Sheeran", "genre": "Pop" }

🗃️ Database Used 📌 SQLite Database File: music.db 🎛️ Managed Using: DB Browser for SQLite 🛠️ Tables are auto-created on server start (via db.js)

🎼 Table Schema: sql CREATE TABLE IF NOT EXISTS songs ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, artist TEXT, genre TEXT );

🌐 Frontend You can open the MusicAPI.html file directly in your browser: 🔗 Features: 1.Add a song using a form 2.View all songs in a list To use: 1.Make sure the server is running. 2.Double-click MusicAPI.html to open it in your browser. 3.Fill in the form and click “Add Song”.

📬 Sample curl Requests Add a Song: bash curl -X POST http://localhost:5000/api/songs
-H "Content-Type: application/json"
-d "{"title":"Test Song", "artist":"Tester", "genre":"Rock"}"

Get All Songs: bash curl http://localhost:5000/api/songs

🛠 Built With 1.Node.js 2.Express.js 3.SQLite3 4.[HTML/CSS/JS] for frontend

📄 License This project is open-source and free to use. Feel free to fork and modify for learning or improvement!

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 60.0%
  • JavaScript 32.2%
  • CSS 7.8%