This project is a Poke-Berries Statistics API that fetches data from the PokeAPI and computes various statistics about berry growth times. The API provides endpoints /allBerryStats
which returns the names of all berries along with statistical data about their growth times and includes an endpoint to view a histogram of berry growth times /showHistogram
.
The application is deployed and can be accessed through the following URLs:
- Fetches data from the PokeAPI to get berry details.
- Computes various statistics such as minimum, maximum, mean, median, variance, and frequency of berry growth times.
- Caches the data for 2 minutes to improve performance.
- Includes content-type header (application/json) in the response.
- Functions are tested using
pytest
.
{
"berries_names": [...],
"min_growth_time": "", // time, int
"median_growth_time": "", // time, float
"max_growth_time": "", // time, int
"variance_growth_time": "", // time, float
"mean_growth_time": "", // time, float
"frequency_growth_time": "" // time, {growth_time: frequency, ...}
}
-
Clone the repository:
git clone https://github.com/your_username/your_repository.git
-
Navigate to the project directory:
cd pokeapi
-
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
# On macOS/Linux source venv/bin/activate # On Windows .\venv\Scripts\activate
-
Install the dependencies:
pip install -r requirements.txt
-
Run the Flask server:
python app.py
-
Access the API in your browser or using a tool like
curl
orPostman
:http://127.0.0.1:5000/allBerryStats
-
View the histogram image directly:
http://127.0.0.1:8000/berryHistogram
-
View the HTML page displaying the histogram:
http://127.0.0.1:8000/showHistogram
-
Build the Docker image:
docker-compose build
-
Run the Docker container:
docker-compose up
-
Access the API:
http://127.0.0.1:8000/allBerryStats
-
View the histogram image directly:
http://127.0.0.1:8000/berryHistogram
-
View the HTML page displaying the histogram:
http://127.0.0.1:8000/showHistogram
To run the tests, use pytest
:
pytest