API Documentation

Complete reference for the IDS Inference API. All endpoints return JSON responses.
Base URL: http://localhost:8094

Quick Start

1. Get Available Datasets

curl http://localhost:8094/datasets

2. Get Available Models

curl http://localhost:8094/models

3. Run Single Inference

curl -X POST http://localhost:8094/infer/single \
  -H "Content-Type: application/json" \
  -d '{
    "dataset": "cic",
    "model_type": "ml",
    "model_name": "cic_cat",
    "features": { "destination_port": 443, "flow_duration": 1234567 }
  }'

Endpoints

GET/datasetsRetrieve list of available datasets with their configurations
GET/modelsRetrieve list of available models for all datasets
POST/infer/singleRun inference on a single data sample
POST/infer/batchRun inference on multiple data samples (JSON array)
POST/infer/uploadRun inference on a CSV or JSON file upload
GET/datasets

Retrieve list of available datasets with their configurations

Response

{
  "type": "array",
  "items": {
    "id": "string (cic | unsw)",
    "name": "string (CIC | UNSW)",
    "labels": "object (class_id: class_name)",
    "features": "array (features used by models after preprocessing)",
    "original_features": "array (original features users can upload)",
    "task": "string (binary | multiclass)"
  }
}

Example

Response:
[
  {
    "id": "cic",
    "name": "CIC",
    "labels": {
      "0": "Normal",
      "1": "DoS",
      "2": "PortScan"
    },
    "features": [
      "destination_port",
      "flow_duration",
      "total_fwd_packets"
    ],
    "original_features": [
      "destination_port",
      "flow_duration",
      "total_fwd_packets"
    ],
    "task": "multiclass"
  }
]

Additional Information

Preprocessing

The API automatically handles preprocessing for uploaded data:

  • Drops index columns (Unnamed: 0, etc.)
  • Drops label columns (label, Label, attack_cat, etc.)
  • Normalizes column names (case-insensitive, handles / vs _)
  • Applies feature engineering (e.g., log1p for UNSW features)
  • Selects and orders features according to model requirements
  • Applies StandardScaler normalization

Supported Models

Machine Learning:
  • CatBoost
  • LightGBM
  • Random Forest
  • XGBoost
  • Extra Trees
Deep Learning:
  • Hybrid GCN with Attention & DQN

Error Handling

The API returns standard HTTP status codes:

  • 200: Success
  • 400: Bad Request (invalid input, missing fields)
  • 404: Model not found
  • 500: Internal server error (model loading/prediction failure)