Skip to main content
POST
/
db
/
detect-anomalies
JavaScript
const url = 'https://api.worqhat.com/db/detect-anomalies';
const options = {
  method: 'POST',
  headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
  body: '{"table":"transactions","k":10,"threshold":0.8,"limit":50,"environment":"production"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
{
  "success": true,
  "anomalies": [
    {
      "record": {},
      "anomaly_score": 0.923,
      "avg_distance": 0.456,
      "nearest_neighbors": [
        {
          "record": {},
          "distance": 0.234
        }
      ]
    }
  ],
  "total_records": 1000,
  "anomaly_count": 15,
  "parameters": {
    "k": 10,
    "threshold": 0.8
  },
  "executionTime": 1247
}

Authorizations

Authorization
string
header
required

API key authentication. Format - "Bearer YOUR_API_KEY"

Body

application/json
table
string
required

Table to analyze for anomalies

Example:

"transactions"

k
number
default:10

Number of nearest neighbors to consider

Required range: 1 <= x <= 50
threshold
number
default:0.8

Minimum anomaly score threshold

Required range: 0 <= x <= 1
limit
number
default:50

Maximum number of anomalies to return

Required range: 1 <= x <= 100
environment
enum<string>

Environment to analyze (development, staging, production)

Available options:
development,
staging,
production
Example:

"production"

Response

Anomaly detection completed successfully

success
boolean
Example:

true

anomalies
object[]
total_records
number

Total number of records analyzed

Example:

1000

anomaly_count
number

Number of anomalies detected

Example:

15

parameters
object
executionTime
number

Analysis execution time in milliseconds

Example:

1247