Giter VIP home page Giter VIP logo

similaritytrakt's Introduction

TraktSimilarity

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

Requirements

  • Go 1.19+
  • Node 14+

Installation

  1. Clone the repository
  2. Update stg_settings.yml with your Trakt API key
  3. 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
  1. Run make run to start the server, it will be available at http://localhost:8080
  2. Enter frontend directory and run npm install to install the frontend dependencies
  3. Run npm run dev to start the frontend
  4. Open http://localhost:3000 in your browser
  5. Play around!

Usage

Showcase

Endpoints

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
    }),
});

Error Handling

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.

similaritytrakt's People

Contributors

dependabot[bot] avatar josemyduarte avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.