The Data Descript API allows users to calculate basic descriptive statistics such as mean, median, variance, standard deviation, minimum and maximum values, range, and quartiles. This is primarily a proof of concept to experiment with FastAPI.
The Data Descript API is built using Python and the FastAPI framework. Ensure you have Python 3.7 or higher installed on your system.
- Programming languages and runtimes:
- Python 3 (≥ 3.7)
- Python packages:
- FastAPI
- uvicorn
- pydantic
- numpy
You can install these packages using the requirements.txt
file provided in the repository.
You can install the Data Descript API by cloning the repository or downloading the latest release.
Cloning the Repository:
git clone https://github.com/glexposito/data-descript-api
cd data-descript-api
Installing Dependencies:
pip install -r requirements.txt
To configure the Data Descript API on your local system, follow these steps:
- Clone the repository as shown in the Installation section.
- Install the necessary dependencies.
- Run the API:
fastapi dev main.py
This will start the API on http://127.0.0.1:8000
.
The Data Descript API provides the following endpoint:
Calculate basic descriptive statistics for your data set:
-
Endpoint:
/descriptive
-
Method:
POST
-
Request Body:
{ "data": [1.0, 2.0, 3.0, 4.0, 5.0] }
-
Response:
{ "mean": 3.0, "median": 3.0, "variance": 2.5, "standard_deviation": 1.5811388300841898, "min": 1.0, "max": 5.0, "range": 4.0, "q1": 2.0, "q2": 3.0, "q3": 4.0 }
Below are some examples of how to use the Data Descript API.
You can use curl
to send a POST request to the /descriptive
endpoint:
curl -X POST "http://127.0.0.1:8000/descriptive" -H "Content-Type: application/json" -d '{"data": [1.0, 2.0, 3.0, 4.0, 5.0]}'
Here's an example of how to use the Python requests
library to interact with the API:
import requests
url = "http://127.0.0.1:8000/descriptive"
data = {
"data": [1.0, 2.0, 3.0, 4.0, 5.0]
}
response = requests.post(url, json=data)
print(response.json())
You can also use the fetch
API in JavaScript to send data to the endpoint:
fetch('http://127.0.0.1:8000/descriptive', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({data: [1.0, 2.0, 3.0, 4.0, 5.0]})
})
.then(response => response.json())
.then(data => console.log(data));