A Pokedex API made with FastAPI
This application needs:
- Postgres database to store data
- .env to get environment variables
pip3 install -r requirements.txt
In this step, we'll learn how to run a web crawler
python3 src/main.py collect
Running the collect command gives you all pokemons and download their images
Waiting for the web crawler to run can be boring and tedious, so we can speed up its collection
In this example, we'll capture the first 15 pokémon
python3 src/main collect --limit --limit-size 15
python3 src/main collect --overwrite
You can combine the limit flag and the override flag
python3 src/main collect --overwrite --limit --limit-size 15
In this step, we'll learn how to send all the data from the web crawler to a database
That is a simple command
python3 src/main.py migrate
In this step, we'll learn how to run the api
python3 src/main start
By default, the host is localhost and the port is 3000
python3 src/main start --host myserver.com --port 8080
By default, the documentation of all API endpoints can be accessed in /docs
http://localhost:3000/docs
I recommend you copy the .env-example
to your .env
COLLECT_FOLDER="./localdb"
STATIC_FOLDER="./static"
MIGRATIONS_FOLDER="./migrations"
POSTGRES_HOST="localhost"
POSTGRES_PORT="5432"
POSTGRES_USER="root"
POSTGRES_PASSWORD="toor"
POSTGRES_DB="pokedex"
- COLLECT_FOLDER
- Is the web crawler directory
- STATIC_FOLDER
- Web crawler download images in this folder
- MIGRATIONS_FOLDER
- In this folder, we have SQL files for creating a database
- POSTGRES_HOST
- Host used to access the database
- POSTGRES_PORT
- Port used to access the database
- POSTGRES_USER
- User used to access the database
- POSTGRES_PASSWORD
- Password used to access the database
- POSTGRES_DB
- Default database name used to access the database
You can run it as a containerized application
Modify the app.sh
to use custom command flags
docker-compose up -d --force-recreate