Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a REST API for third party usage #224

Open
4 of 9 tasks
leepeuker opened this issue Jan 11, 2023 · 4 comments · Fixed by #486, #487, #494, #506 or #507
Open
4 of 9 tasks

Add a REST API for third party usage #224

leepeuker opened this issue Jan 11, 2023 · 4 comments · Fixed by #486, #487, #494, #506 or #507
Labels
enhancement New feature or request

Comments

@leepeuker
Copy link
Owner

leepeuker commented Jan 11, 2023

The current most http routes used have a state (php session) and are not suitable for third party usages.

Structure proposal:

  • /users/{username}/history/movies (movies with watch dates ordered by last played)
  • /users/{username}/watchlist/movies (movies on the users watchlist ordered by the date of the addition to the list)
  • /users/{username}/played/movies (all movies with user plays)
  • /movies (get all local movies)
  • /movies/search (search for movies, including remote results from tmdb)
  • /movies/sync (import or update existing movie, either movaryId OR tmdbId required)
  • /jobs/{jopType} (CRUD for server background jobs)
  • /users/{username}/settings/general (CRUD for user general setttings)
  • /users/{username}/settings/security (CRUD for user security setttings)

Other:

  • All routes have the prefix /api
  • Routes can require a valid auth token. The auth token is set via http header X-Auth-Token. Every user account can re/generate their X-Auth-Token (token and user are hardly coupled). This is a really basic setup which can be improved later, for now I would like to focus on functionality over security.

TODO: add api token and its management to user general account settings, maybe under new section Api

@leepeuker leepeuker added the enhancement New feature or request label Jan 11, 2023
@leepeuker leepeuker changed the title Add a REST API Add a REST API for third party usage Feb 15, 2023
This was linked to pull requests Sep 2, 2023
@leepeuker
Copy link
Owner Author

The basics were added together with the first api endpoint (history). The rest of the endpoints has to follow.

@leepeuker leepeuker reopened this Sep 2, 2023
@leepeuker leepeuker linked a pull request Sep 15, 2023 that will close this issue
@JVT038
Copy link
Collaborator

JVT038 commented Sep 16, 2023

Some other suggestions:

  • /users/{username}/settings/general/username (PUT) - Change the username
  • /users/{username}/settings/general/dateformat (PUT) - Change the user's date format
  • /users/{username}/settings/general/privacy (PUT) - Change the privacy level; accepts an integer, based on the level
  • /users/{username}/settings/general/country (PUT) - Change the country
  • /users/{username}/settings/general/watchlistremoval (PUT) - Toggle the automatic removal from the watchlist if an item is played
  • /users/{username}/settings/security/password (PUT) - Change the password

@leepeuker
Copy link
Owner Author

leepeuker commented Sep 17, 2023

@JVT038 true, I have added the following to the TODO

- /users/{username}/settings/general (CRUD for user general setttings)
- /users/{username}/settings/security (CRUD for user security setttings)

I think I would prefer to create just one endpoint per settings type with optional values instead of one endpoint settings type value 🤔

@leepeuker
Copy link
Owner Author

leepeuker commented Sep 17, 2023

We need to improve the rest API stability. Incorrect requested payloads lead to 500 server errors.

Additionally, we return the frontend 500/404 responses pages for server errors. The rest API response should be JSON and not html.

Edit: Fixed wrong error pages for API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment