This API is part of the Machine Learning Engineering FIAP Pos-Tech program. It provides a programmatic way to access data from the Embrapa website and allows users to retrieve relevant information through well-defined endpoints.
The application uses environment variables for configuration. Ensure the following variables are set:
You can set these variables in a .env file in the root directory:
MONGO_INITDB_ROOT_USERNAME=your_mongo_username
MONGO_INITDB_ROOT_PASSWORD=your_mongo_password
JWT_SECRET_KEY=your_jwt_secret_key
JWT_ALGORITHM=HS256
JWT_TOKEN_EXPIRE_MINUTES=15
Build and Start with Docker Compose
docker-compose up --build -d
First you have to scrap the Embrapa website data by running the following command:
python -m src.helpers.scrapper.async_web_scrapper
Alternatively you can uncomment the web-scrapping portion from app.py
.
The database is populated automatically when the application starts for the first time.
The API provides endpoints for accessing production, processing, trade, import, and export data from the Embrapa website.
GET /docs
- Interactive Swagger documentation.
GET /auth/token
- Generate a JWT token for authentication.
GET /production/{year}
- Retrieve data on the production of wines, juices, and estimates in Rio Grande do Sul.
GET /processing/{year}
-Retrieve data on the quantity of grapes processed in Rio Grande do Sul.
GET /trading/{year}
- Retrieve data on the commercialization of wines and derivatives in Rio Grande do Sul.
GET /import/{year}
- Retrieve data on the import of grape derivatives.
GET /export/{year}
- Retrieve data on the export of grape derivatives.
curl -X GET \
"http://localhost:8000/auth/token" \
-H "accept: application/json"
curl -X GET \
"http://127.0.0.1:8000/production/2022" \
-H "accept: application/json" \
-H "Authorization: Bearer <your-token>"
Alternatively, the project has a collection of endpoint calls that can be called by Bruno and can also be used by the swagger documentation.