curl -X POST http://localhost:8000/predict \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"features": {
"hr": 14,
"temp": 0.5,
"hum": 0.6,
"weathersit": 1,
"weekday": 2
}
}'
import requests
response = requests.post(
"http://localhost:8000/predict",
headers={"X-API-Key": "your-api-key"},
json={
"features": {
"hr": 14, "temp": 0.5, "hum": 0.6,
"weathersit": 1, "weekday": 2
}
}
)
print(response.json())
{
"prediction": 145.2,
"confidence": 0.75,
"model_version": "production",
"model_id": "production",
"timestamp": "2025-01-15T14:30:00"
}
{
"detail": "Invalid or missing API key"
}
{
"detail": "Rate limit exceeded. Try again in 60 seconds."
}
Generate Forecast
Submit feature values and receive a demand prediction with confidence score and model metadata
POST
/
predict
curl -X POST http://localhost:8000/predict \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"features": {
"hr": 14,
"temp": 0.5,
"hum": 0.6,
"weathersit": 1,
"weekday": 2
}
}'
import requests
response = requests.post(
"http://localhost:8000/predict",
headers={"X-API-Key": "your-api-key"},
json={
"features": {
"hr": 14, "temp": 0.5, "hum": 0.6,
"weathersit": 1, "weekday": 2
}
}
)
print(response.json())
{
"prediction": 145.2,
"confidence": 0.75,
"model_version": "production",
"model_id": "production",
"timestamp": "2025-01-15T14:30:00"
}
{
"detail": "Invalid or missing API key"
}
{
"detail": "Rate limit exceeded. Try again in 60 seconds."
}
Generates a demand forecast for a single data point. Requires API key authentication.
Authentication
string
required
API key for authentication. Verified server-side using Argon2id hashing with constant-time comparison.
Parameters
object
required
Dictionary of input features for the model.
Show Feature fields
Show Feature fields
integer
required
Hour of the day (0–23).
float
required
Normalized temperature (0–1).
float
required
Normalized humidity (0–1).
integer
required
Weather condition code (1–4): 1=Clear, 2=Mist, 3=Light rain, 4=Heavy rain.
integer
required
Day of week (0=Sunday, 6=Saturday).
float
Normalized wind speed (0–1). Optional.
Response
float
required
Predicted bike rental count for the given conditions.
float
required
Prediction confidence score (0.50–0.95).
string
required
Always
"production" for the primary model.string
required
Identifier for the model that served the request (e.g.,
"production" or "challenger").string
required
ISO 8601 timestamp of when the prediction was generated.
curl -X POST http://localhost:8000/predict \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"features": {
"hr": 14,
"temp": 0.5,
"hum": 0.6,
"weathersit": 1,
"weekday": 2
}
}'
import requests
response = requests.post(
"http://localhost:8000/predict",
headers={"X-API-Key": "your-api-key"},
json={
"features": {
"hr": 14, "temp": 0.5, "hum": 0.6,
"weathersit": 1, "weekday": 2
}
}
)
print(response.json())
{
"prediction": 145.2,
"confidence": 0.75,
"model_version": "production",
"model_id": "production",
"timestamp": "2025-01-15T14:30:00"
}
{
"detail": "Invalid or missing API key"
}
{
"detail": "Rate limit exceeded. Try again in 60 seconds."
}
Body
application/json
Key-value pairs of features
Example:
{
"temp": 0.5,
"humidity": 0.6,
"wind_speed": 0.2,
"hour": 14,
"day_of_week": 3
}
Was this page helpful?
