Skip to content

sayhan1610/matchmytaste

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MatchMyTaste API

Overview

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.

Accessing the API

You can use the MatchMyTaste API in three ways: directly from the provided URL, by visiting the website, or by setting it up locally.

1. Use the Existing API

The API is hosted and can be accessed from https://matchmytaste.onrender.com/.

Endpoints

Ping
  • Endpoint: /ping
  • Method: GET
  • Description: Returns "pong" to check if the API is running.
Search for Similar Artists
  • 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.
Search for Similar Tracks
  • 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.
Fetch Top Tracks of the Month
  • 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.

Example Requests

Ping

curl -X GET "https://matchmytaste.onrender.com/ping"

Search for Similar Artists

curl -X POST "https://matchmytaste.onrender.com/search_artist" -H "Content-Type: application/json" -d '{"query": "artist_name"}'

Search for Similar Tracks

curl -X POST "https://matchmytaste.onrender.com/search_track" -H "Content-Type: application/json" -d '{"query": "track_name"}'

Fetch Top Tracks of the Month

curl -X GET "https://matchmytaste.onrender.com/top_tracks_of_month"

2. Use the Website

Visit the MatchMyTaste website to easily access the API features through a user-friendly interface: https://matchmytaste.netlify.app/.

3. Use it Locally

Follow these steps to set up and run the API on your local machine.

Prerequisites

  • Python 3.7+
  • Spotify API credentials (Client ID and Client Secret)

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/MatchMyTaste-api.git
    cd MatchMyTaste-api
  2. Install dependencies from requirements.txt:

    pip install -r requirements.txt
  3. 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'
  4. Run the FastAPI application using Uvicorn:

    uvicorn main:app --reload

Local Endpoints

The endpoints are the same as those listed above but will be accessed at http://127.0.0.1:8000.

Example Requests

Ping

curl -X GET "http://127.0.0.1:8000/ping"

Search for Similar Artists

curl -X POST "http://127.0.0.1:8000/search_artist" -H "Content-Type: application/json" -d '{"query": "artist_name"}'

Search for Similar Tracks

curl -X POST "http://127.0.0.1:8000/search_track" -H "Content-Type: application/json" -d '{"query": "track_name"}'

Fetch Top Tracks of the Month

curl -X GET "http://127.0.0.1:8000/top_tracks_of_month"

Error Handling

  • 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published