Bankole Synthetic Sensor API
A FastAPI-powered synthetic data engine that streams realistic IoT sensor readings for prototyping, testing, and demonstration. Generate configurable accelerometer, gyroscope, and environmental sensor data on demand through a simple REST interface.
Sample Dataset Preview
A synthetic sensor dataset with 60 records spanning accelerometer vibration, temperature, pressure, and soil moisture readings. Some entries simulate sensor anomalies (high temperature, pressure, and moisture) for testing detection logic.
| timestamp | vibration | temperature | pressure | soil_moisture | anomaly |
|---|---|---|---|---|---|
| 0 | 0.013378907718622983 | 19.887993997169936 | 101.29934940739335 | 30.275496537022644 | false |
| 1 | -0.0051279438967971255 | 20.218571999896525 | 101.50264340584152 | 30.00539624923254 | false |
| 2 | 0.026788528337124532 | 19.903476405480728 | 101.27622223492813 | 30.086205501401068 | false |
| 3 | 0.13179823650671166 | 20.241845048629045 | 101.13957051142104 | 29.868081090893888 | false |
| 4 | -0.04599942146030294 | 19.919334812087254 | 101.5130935673119 | 29.948828521732473 | false |
Quickstart - Python
Install the requests library and call the /stream endpoint to receive a batch of synthetic sensor readings.
import requests
url = "http://localhost:8000/stream"
params = {"sample_rate_hz": 10, "duration_seconds": 5}
response = requests.get(url, params=params)
data = response.json()
print(data)Quickstart - cURL
Use cURL to fetch synthetic data directly from the command line:
curl "http://localhost:8000/stream?sample_rate_hz=10&duration_seconds=5"Live Sample Response
Fetch a live 5-second sample at 1 Hz from the running API server:
Integration Instructions
Run the FastAPI server locally to serve synthetic sensor data:
1. Install Dependencies
pip install fastapi uvicorn pydantic numpy2. Start the Server
From the directory containing sensor_synthetic_data.py, run:
uvicorn sensor_synthetic_data:app --reloadThe API will be available at http://localhost:8000. The --reload flag enables hot-reloading during development.
3. Calling from Other Languages
The API returns JSON, so you can call it from any language. Here is a JavaScript example using the Fetch API (browser or Node.js):
fetch("http://localhost:8000/stream?sample_rate_hz=10&duration_seconds=5")
.then((res) => res.json())
.then((data) => console.log(data));