https://github.com/infectedduck/flask-music_api
A REST API for managing a music collection using MongoDB. Features CRUD operations, health checks, and more. Ideal for integrating music data management into your applications.
https://github.com/infectedduck/flask-music_api
Last synced: about 2 months ago
JSON representation
A REST API for managing a music collection using MongoDB. Features CRUD operations, health checks, and more. Ideal for integrating music data management into your applications.
- Host: GitHub
- URL: https://github.com/infectedduck/flask-music_api
- Owner: InfectedDuck
- License: apache-2.0
- Created: 2024-09-01T06:29:51.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-14T00:15:39.000Z (almost 2 years ago)
- Last Synced: 2025-03-05T11:35:14.816Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flask Music API
## Overview
This project is a Flask-based REST API for managing a music collection. It provides endpoints for CRUD operations on songs stored in a MongoDB database. The API includes features for health checks, counting records, retrieving all songs, fetching a song by ID, creating, updating, and deleting songs.
## Features
* **Health Check**: Endpoint to verify the API is running.
* **Count Records**: Endpoint to get the total number of songs in the database.
* **Retrieve All Songs**: Fetch all songs from the database.
* **Retrieve Song by ID**: Get details of a specific song using its ID.
* **Create Song**: Add a new song to the database.
* **Update Song**: Modify details of an existing song.
* **Delete Song**: Remove a song from the database.
## Getting Started
### Prerequisites
* **Python**: Ensure Python 3.x is installed.
* **Flask**: Install Flask using pip.
* **pymongo**: Install pymongo using pip.
### Configuration
Set the following environment variables for MongoDB connection:
- **`MONGODB_SERVICE`**: MongoDB server address.
- **`MONGODB_USERNAME`**: MongoDB username (if authentication is used).
- **`MONGODB_PASSWORD`**: MongoDB password (if authentication is used).
- **`MONGODB_PORT`**: MongoDB port (optional).
### API Endpoints
- **GET `/health`**:
Returns the health status of the API.
- **GET `/count`**:
Returns the total number of songs in the database.
- **GET `/song`**:
Retrieves all songs.
- **GET `/song/`**:
Retrieves a song by ID.
- **POST `/song`**:
Creates a new song.
- **PUT `/song/`**:
Updates an existing song.
- **DELETE `/song/`**:
Deletes a song by ID.
## License
This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details.
This project is made as a part of IBM Course.