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

https://datfid-org-datfid-master.hf.space

Authentication

Protected routes require your DATFID token in the Authorization header. See Get Your API Key to obtain a token.

Authorization: Bearer dt+YOUR_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.

MethodPathPurposeAuth
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

FieldTypeRequiredDescription
fileFile
Yes
Excel or CSV file with panel data
id_colString
Yes
Entity column name
time_colString
Yes
Time column name
yString
Yes
Target variable column name
current_featuresString
No
"all" or comma-separated feature names
lag_yString
No
Lag range for target, e.g. "1:5" includes the 1st through 5th lagged values of the target as predictors
lagged_featuresJSON 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

Terminal
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.txt

POST
/modelforecast-file/

Generates forecasts using a previously fitted model. Accepts a forecast data file and returns predictions as a CSV.

Request Parameters

FieldTypeRequiredDescription
df_forecastFile
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

Terminal
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.csv

Using Postman

You can also test file-upload routes with Postman:

  1. Create two variables: public_url = https://datfid-org-datfid-master.hf.space, and datfid_token = dt+YOUR_TOKEN.
  2. Set collection-level auth to Bearer Token using {{datfid_token}}.
  3. 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

CodeMeaningTypical Cause / Fix
200
OKRequest succeeded
400
Bad RequestMissing fields; forecast called before fit
401
UnauthorizedMissing or invalid Authorization header / token
403
ForbiddenToken expired or not whitelisted
413
Payload Too LargeFile exceeds limit; upload smaller parts
5xx
Server ErrorTemporary issue; retry or contact DATFID