TraktSimilarity is a Go application that uses the Trakt.tv API to calculate the similarity between the watchlists of two users. It is a REST application that takes two users and returns a similarity score between 0 and 1.
This application was created as an exercise to experiment with Github Copilot and ChatGPT. Most of the code was written by the AI, most of the effort made by me was finding ways to ask properly what I wanted, and fixing the code to make it work. There is much room for improvement, but the intention wasn't to start a new business but to learn and have fun and I did 😁.
Disclaimer: I'm not good with frontend and JS, so the frontend is not the best, but it works (at least the happy path).
- Go 1.19+
- Node 14+
- Clone the repository
- Update stg_settings.yml with your Trakt API key
- Create a .env.local inside
frontend
folder with the following content:
TRAKT_CLIENT_ID=[YOUR_CLIENT_ID]
TRAKT_CLIENT_SECRET=[YOUR_CLIENT_SECRET]
AUTH_SECRET=YourSecret
NEXTAUTH_URL=http://localhost:3000
- Run
make run
to start the server, it will be available athttp://localhost:8080
- Enter
frontend
directory and runnpm install
to install the frontend dependencies - Run
npm run dev
to start the frontend - Open
http://localhost:3000
in your browser - Play around!
All endpoints require a valid Trakt access token to be passed in the Authorization
header.
GET /trakt/watchlist
: Returns the watchlist for a given user
const res = await fetch("http://localhost:8080/trakt/watchlist", {
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
});
GET /trakt/similarity
: Returns the similarity score between the owner of the access token and another user
const res = await fetch("http://localhost:8080/trakt/similarity", {
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
other_username: username, // username of the other user to compare
}),
});
If an error occurs, the server will respond with a JSON object containing an error message and an HTTP status code indicating the type of error.