REST API Reference
Use DATFID directly via HTTP endpoints. File-upload routes use multipart/form-data and accept Excel (.xlsx, .xls) or CSV (.csv) files. Authentication uses the Authorization: Bearer header.
Base URL
Authentication
Protected routes require your DATFID token in the Authorization header. See Get Your API Key to obtain a token.
Which routes need auth? GET / (health check) requires no token. All other routes (/secure-ping/, /modelfit*, /modelforecast*) require a valid DATFID token.
Endpoint Overview
Use the SDK for JSON routes and cURL/Postman for file-upload routes.
| Method | Path | Purpose | Auth |
|---|---|---|---|
GET | / | Health check (liveness) | No |
GET | /secure-ping/ | Verify your DATFID token | Yes |
POST | /modelfit/ | Fit model (SDK JSON) | Yes |
POST | /modelforecast/ | Forecast (SDK JSON) | Yes |
POST | /modelfit-file/ | Fit model (file upload) | Yes |
POST | /modelforecast-file/ | Forecast (file upload) | Yes |
POST/modelfit-file/
Trains an interpretable model on your panel data. Returns a plain-text summary of the analysis results.
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
file | File | Yes | Excel or CSV file with panel data |
id_col | String | Yes | Entity column name |
time_col | String | Yes | Time column name |
y | String | Yes | Target variable column name |
current_features | String | No | "all" or comma-separated feature names |
lag_y | String | No | Lag range for target, e.g. "1:5" includes the 1st through 5th lagged values of the target as predictors |
lagged_features | JSON String | No | JSON object mapping feature names to lag ranges, e.g. {"Income Level":"1:3"} |
Response
result.txt - a plain-text file attachment with the human-readable analysis summary.
cURL Example
curl -X POST "https://datfid-org-datfid-master.hf.space/modelfit-file/" \
-H "Authorization: Bearer dt+YOUR_TOKEN" \
-F "file=@Banking_extended.xlsx" \
-F "id_col=Individual" \
-F "time_col=Time" \
-F "y=Loan Probability" \
-F "current_features=all" \
-F "lag_y=1:5" \
-o result.txtPOST/modelforecast-file/
Generates forecasts using a previously fitted model. Accepts a forecast data file and returns predictions as a CSV.
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
df_forecast | File | Yes | Excel or CSV file defining entities/periods to predict |
Response
forecast.csv - a CSV file with row-aligned predictions for each entity and time point.
cURL Example
curl -X POST "https://datfid-org-datfid-master.hf.space/modelforecast-file/" \
-H "Authorization: Bearer dt+YOUR_TOKEN" \
-F "df_forecast=@Banking_extended_forecast.xlsx" \
-o forecast.csvUsing Postman
You can also test file-upload routes with Postman:
- Create two variables:
public_url=https://datfid-org-datfid-master.hf.space, anddatfid_token=dt+YOUR_TOKEN. - Set collection-level auth to Bearer Token using
{{datfid_token}}. - Create requests:
- GET
{{public_url}}/(no auth needed) - GET
{{public_url}}/secure-ping/(auth required) - POST
{{public_url}}/modelfit-file/(form-data with file + params) - POST
{{public_url}}/modelforecast-file/(form-data with forecast file)
Status Codes
| Code | Meaning | Typical Cause / Fix |
|---|---|---|
200 | OK | Request succeeded |
400 | Bad Request | Missing fields; forecast called before fit |
401 | Unauthorized | Missing or invalid Authorization header / token |
403 | Forbidden | Token expired or not whitelisted |
413 | Payload Too Large | File exceeds limit; upload smaller parts |
5xx | Server Error | Temporary issue; retry or contact DATFID |