MatchMyTaste API is a web service built with FastAPI to retrieve information about music artists and tracks. It interacts with the Spotify API to search for similar artists, similar tracks, and fetch the top tracks of the month based on user queries.
You can use the MatchMyTaste API in three ways: directly from the provided URL, by visiting the website, or by setting it up locally.
The API is hosted and can be accessed from https://matchmytaste.onrender.com/.
- Endpoint:
/ping
- Method: GET
- Description: Returns "pong" to check if the API is running.
- Endpoint:
/search_artist
- Method: POST
- Description: Returns a list of similar artists based on the provided artist name or query.
- Input: JSON body
{ "query": "artist_name" }
- Output: List of artists with their names and Spotify URLs.
- Endpoint:
/search_track
- Method: POST
- Description: Returns a list of similar tracks based on the provided track name or query.
- Input: JSON body
{ "query": "track_name" }
- Output: List of tracks with their names, artists, and Spotify URLs.
- Endpoint:
/top_tracks_of_month
- Method: GET
- Description: Fetches the top tracks of the current month based on Spotify's popularity metrics.
- Output: List of tracks with their names, artists, and Spotify URLs.
curl -X GET "https://matchmytaste.onrender.com/ping"
curl -X POST "https://matchmytaste.onrender.com/search_artist" -H "Content-Type: application/json" -d '{"query": "artist_name"}'
curl -X POST "https://matchmytaste.onrender.com/search_track" -H "Content-Type: application/json" -d '{"query": "track_name"}'
curl -X GET "https://matchmytaste.onrender.com/top_tracks_of_month"
Visit the MatchMyTaste website to easily access the API features through a user-friendly interface: https://matchmytaste.netlify.app/.
Follow these steps to set up and run the API on your local machine.
- Python 3.7+
- Spotify API credentials (Client ID and Client Secret)
-
Clone the repository:
git clone https://github.com/yourusername/MatchMyTaste-api.git cd MatchMyTaste-api
-
Install dependencies from
requirements.txt
:pip install -r requirements.txt
-
Set up your Spotify API credentials in the environment variables:
export SPOTIPY_CLIENT_ID='your_spotify_client_id' export SPOTIPY_CLIENT_SECRET='your_spotify_client_secret'
-
Run the FastAPI application using Uvicorn:
uvicorn main:app --reload
The endpoints are the same as those listed above but will be accessed at http://127.0.0.1:8000
.
curl -X GET "http://127.0.0.1:8000/ping"
curl -X POST "http://127.0.0.1:8000/search_artist" -H "Content-Type: application/json" -d '{"query": "artist_name"}'
curl -X POST "http://127.0.0.1:8000/search_track" -H "Content-Type: application/json" -d '{"query": "track_name"}'
curl -X GET "http://127.0.0.1:8000/top_tracks_of_month"
- 400 Bad Request: Returned if the input query is missing or malformed.
- 401 Unauthorized: Returned if the Spotify API credentials are invalid.
- 500 Internal Server Error: Returned if there is an issue with the Spotify API or server.