This project provides a lightweight and easy-to-use interface for extracting data from Transfermarkt by applying web scraping processes and offering a RESTful API service via FastAPI. With this service, developers can seamlessly integrate Transfermarkt data into their applications, websites, or data analysis pipelines.
Please note that the deployed application is used only for testing purposes and has a rate limiting feature enabled. If you'd like to customize it, consider hosting in your own cloud service.
https://transfermarkt-api.fly.dev/
# Clone the repository
$ git clone https://github.com/felipeall/transfermarkt-api.git
# Go to the project's root folder
$ cd transfermarkt-api
# Instantiate a Poetry virtual env
$ poetry shell
# Install the dependencies
$ poetry install --no-root
# (optional) Append the current directory to PYTHONPATH
$ export PYTHONPATH=$PYTHONPATH:$(pwd)
# Start the API server
$ python app/main.py
# Access the API local page
$ open http://localhost:8000/# Clone the repository
$ git clone https://github.com/felipeall/transfermarkt-api.git
# Go to the project's root folder
$ cd transfermarkt-api
# Build the Docker image
$ docker build -t transfermarkt-api .
# Instantiate the Docker container
$ docker run -d -p 8000:8000 transfermarkt-api
# Access the API local page
$ open http://localhost:8000/| Variable | Description | Default |
|---|---|---|
RATE_LIMITING_ENABLE |
Enable rate limiting feature for API calls | false |
RATE_LIMITING_FREQUENCY |
Delay allowed between each API call. See slowapi for more | 2/3seconds |
TOURNAMENT_SIZE_FIWC |
Expected number of participants for World Cup | 32 |
TOURNAMENT_SIZE_EURO |
Expected number of participants for UEFA Euro | 24 |
TOURNAMENT_SIZE_COPA |
Expected number of participants for Copa America | 12 |
TOURNAMENT_SIZE_AFAC |
Expected number of participants for AFC Asian Cup | 24 |
TOURNAMENT_SIZE_GOCU |
Expected number of participants for Gold Cup | 16 |
TOURNAMENT_SIZE_AFCN |
Expected number of participants for Africa Cup of Nations | 24 |
Note: Tournament size variables are used to limit participant lists for national team competitions, excluding non-qualified teams. If a tournament size is not configured or becomes outdated, a warning will be logged and all participants will be included without truncation.