The F1 Results API is a lightweight and efficient service designed to provide access to Formula 1 race result data.
This API is built with Go, utilizing the Chi router for efficient routing and includes CORS support for cross-origin requests.
- Fetch a list of all F1 tracks for a specific year
- Fetch information about a specific track
- Retrieve race results for a particular year
- Get race results for a specific track in a given year
- Comprehensive test coverage
- Swagger documentation
The API provides the following endpoints:
GET f1/api/getTracks/{year}
: Retrieve all tracks for a specific yearGET f1/api/getTracks/{year}/{trackName}
: Get information about a specific track in a given yearGET f1/api/getResults/{year}
: Retrieve all race results for a specific yearGET f1/api/getResult/{year}/{trackId}
: Get race results for a specific track in a given yearGET f1/api/swagger/
: Swagger documentation
For detailed information about request parameters, responses, and possible error codes, please refer to the Swagger documentation.
- PostgreSQL database
- Make (for using Makefile)
-
Clone the repository:
git clone https://github.com/kamildemocko/F1ResultsAPI.git
-
Navigate to the project directory:
cd F1ResultsAPI
-
Install dependencies:
go mod tidy
-
Set up your environment variables in a
.env
file:DSN=your_postgresql_connection_string
-
Build the application:
go run .\cmd\api
-
Build the Docker image:
docker build -t f1-results-api .
-
Run the Docker container:
docker run -p 8080:80 -d --name f1-results-api-run --network postgres f1-results-api
The API will be available at http://localhost/f1/api
.