Skip to content

API Documentation

oguzhekim edited this page Dec 18, 2024 · 3 revisions

This the API documentation for FitnessFact. There are general information about endpoints in this wikipage. In order to see example request and response formats for each endpoint open the OpenAPI specification file in Swagger Editor.

Authorization Overview

The API requires authentication for certain endpoints to ensure that only authorized users can perform specific actions. To authenticate, you need to obtain a session token via the login process, which should be included in the x-session-token header for all protected endpoints.

Authentication Flow

  1. Register: New users can register via the /auth/register endpoint.
  2. Login: Once registered, users can log in using the /auth/login endpoint. After successful login, a session token will be returned, which should be included in the x-session-token header for subsequent requests that require authentication.
  3. Logout: To log out and invalidate the session, use the /auth/logout endpoint.

Authorization Header

For endpoints that require authentication, you must include the x-session-token in the request header.

Example of how to include the token in the request header:

x-session-token: <session_token>

Authentication Endpoints

Method Endpoint Description Authentication
POST /auth/register Register a new user in the system. No
POST /auth/login Log in a user and retrieve a session token. No
POST /auth/logout Log out the authenticated user. Yes
GET /auth/user Retrieve the authenticated user's profile. Yes

User Endpoints

Method Endpoint Description Authentication
GET /api/user/{username} Retrieve user profile by username. No
POST /api/user/{username}/follow Follow a user by username. Yes
DELETE /api/user/{username}/follow Unfollow a user by username. Yes
GET /api/user/{username}/following Get the list of users that the specified user is following. No
GET /api/user/{username}/followers Get the list of followers of the specified user. No

Post Endpoints

Method Endpoint Description Authentication
GET /api/posts Fetch all posts. Optionally filter by tags (tags). No
POST /api/posts Create a new post with content and tags. Yes
GET /api/posts/user/{username} Retrieve posts created by a specific user. No
GET /api/posts/random Fetch random posts. Optionally, specify count (count). No
POST /api/posts/{postId}/like Like a specific post. Yes
DELETE /api/posts/{postId}/like Unlike a specific post. Yes
POST /api/posts/{postId}/bookmark Bookmark a specific post. Yes
DELETE /api/posts/{postId}/bookmark Remove bookmark from a specific post. Yes
GET /api/posts/bookmarked Retrieve bookmarked posts of the authenticated user. Yes
DELETE /api/posts/{postId} Delete a specific post created by the authenticated user. Yes
GET /api/posts/for-you Fetch posts personalized to the user's fitness goals. Supports pagination with page and size parameters. Yes
GET /api/posts/explore Fetch posts filtered by tags or explore all. Supports pagination with page and size parameters. No

Search Endpoints

Method Endpoint Description Authentication
GET /api/search Search for resources using a query parameter (q). No

Training Program Endpoints

Method Endpoint Description Authentication
GET /api/training-programs Retrieve all training programs. No
POST /api/training-programs Create a new training program. Yes
GET /api/training-programs/{id} Retrieve a training program by ID. No
DELETE /api/training-programs/{id} Delete a specific training program by ID. Yes
GET /api/training-programs/{trackingId}/completion-rates Get completion rates for exercises in a training program. Yes
GET /api/training-programs/{programId}/participants Get a list of usernames of participants in a training program. No
POST /api/training-programs/{programId}/join Join a specific training program. Yes
DELETE /api/training-programs/{programId}/leave Leave a specific training program. Yes
POST /api/training-programs/{programId}/workout-exercises/{workoutExerciseId}/complete Mark an exercise as completed in a training program. Yes
GET /api/training-programs/trainer/{username} Get all training programs by a specific trainer. No
GET /api/training-programs/joined/{username} Get all training programs that a user has joined. Yes
GET /api/training-programs/tracking/{trackingId} Get training program with tracking information. Yes
GET /api/training-programs/recommended Get recommended training programs with pagination. Yes
GET /api/training-programs/ongoing/{trainingProgramId} Get ongoing training program with tracking details. Yes
GET /api/training-programs/explore Explore available training programs with pagination. Yes
GET /api/training-programs/{trainingProgramId}/rate Get the user's rating for a training program. Yes
POST /api/training-programs/{trainingProgramId}/rate Rate a specific training program. Yes

Exercise Endpoints

Method Endpoint Description Authentication
GET /api/exercises Retrieve all exercises available in the system. No
GET /api/exercises/{id} Retrieve details of a specific exercise by its ID. No
GET /api/exercises/{id}/progress Retrieve the authenticated user's historical daily progress for an exercise. Yes

Tag Endpoints

Method Endpoint Description Authentication
GET /api/tags Retrieve all available tags. No

Survey Endpoints

Method Endpoint Description Authentication
GET /api/surveys/user Retrieve surveys completed by the authenticated user. Yes
POST /api/surveys Submit survey. Yes
GET /api/surveys/fitness-goals Retrieve the fitness goals of the authenticated user. Yes
POST /api/surveys/fitness-goals Add fitness goals for the authenticated user. Yes
DELETE /api/surveys/fitness-goals Remove fitness goals of the authenticated user. Yes

Feedback Endpoints

Method Endpoint Description Authentication
POST /api/feedback Submit feedback. Yes
GET /api/feedback/user/{username} Retrieve feedback for a specific user by username. Yes
GET /api/feedback/training-program/{id} Retrieve feedback for a specific training program by ID. Yes
Cmpe 352 Archive
Clone this wiki locally