The UFC Fight Tracking API is a RESTful API designed to manage and track UFC fighters, their rankings, and user favorites. This API allows users to register, log in, and manage their favorite fighters while providing detailed information about fighters and their rankings.
- User registration and authentication
- Manage favorite fighters
- Search and filter fighters based on various criteria
- Retrieve fighter rankings by weight class
- Swagger documentation for easy API exploration
- Go (Golang)
- Echo framework for building the API
- GORM for ORM (Object Relational Mapping)
- PostgreSQL for the database
- JWT (JSON Web Tokens) for authentication
- Swagger for API documentation
- Go (1.16 or later)
- PostgreSQL
- Go modules
-
Clone the repository:
git clone https://github.com/telman03/ufc.git cd ufc
-
Create a
.env
file in the root directory and add your database configuration:DB_HOST=localhost DB_USER=your_db_user DB_PASSWORD=your_db_password DB_NAME=your_db_name DB_PORT=5432 JWT_SECRET=your_jwt_secret
-
Install the required Go packages:
go mod tidy
-
Run the database migrations:
go run main.go
To start the API server, run:
go run main.go
The server will start on http://localhost:8080
.
-
Register User
POST /register
- Request Body:
{"username": "testuser", "email": "user@example.com", "password": "123456"}
-
Login User
POST /login
- Request Body:
{"email": "user@example.com", "password": "123456"}
-
Search Fighters
GET /fighters
- Query Parameters:
name
,stance
,weight
,wins
,losses
,limit
,offset
-
Manage Favorites
- Add Favorite:
POST /favorites
- Request Body:
{"fighter_id": 1}
- Request Body:
- Remove Favorite:
DELETE /favorites/{fighter_id}
- List Favorites:
GET /favorites
- Add Favorite:
- Get Rankings by Weight Class
GET /rankings
- Query Parameter:
weightclass
The API is documented using Swagger. You can access the documentation at:
http://localhost:8080/swagger/index.html
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License - see the LICENSE file for details.