API Documentation

Complete guide to integrating the NCS-API into your applications. Get started in minutes with our comprehensive documentation and interactive examples.

Introduction

Welcome to the NCS-API documentation! The Neural Clustering System API provides high-performance clustering algorithms through a simple REST interface. Our API supports multiple clustering algorithms including K-Means, DBSCAN, Hierarchical clustering, and our proprietary NCS Neural algorithm.

Base URL: https://api.ncs-clustering.com/v1

Key Features

  • Process up to 1M data points in real-time
  • Sub-100ms response times for most operations
  • Multiple clustering algorithms with automatic parameter optimization
  • Built-in data validation and preprocessing
  • Comprehensive metrics and quality scoring
  • WebSocket support for real-time streaming

Quick Start

Get up and running with the NCS-API in under 5 minutes. Here's a simple example to perform clustering on your data:

// Install: npm install @ncs-api/client
import { NCSClient } from '@ncs-api/client';

const client = new NCSClient({
  apiKey: 'your-api-key',
  baseURL: 'https://api.ncs-clustering.com/v1'
});

// Prepare your data
const data = [
  { x: 1.5, y: 2.3, feature3: 0.8 },
  { x: 2.1, y: 1.9, feature3: 1.2 },
  { x: 3.4, y: 4.1, feature3: 2.1 }
  // ... more data points
];

// Run clustering
async function runClustering() {
  try {
    const result = await client.cluster({
      algorithm: 'ncs',
      data: data,
      parameters: {
        neuralDepth: 3,
        learningRate: 0.05
      }
    });
    
    console.log('Clusters found:', result.clusters);
    console.log('Processing time:', result.processingTime);
    console.log('Quality metrics:', result.metrics);
  } catch (error) {
    console.error('Clustering failed:', error);
  }
}

runClustering();
# Install: pip install ncs-api-client
from ncs_api import NCSClient
import pandas as pd

# Initialize client
client = NCSClient(
    api_key='your-api-key',
    base_url='https://api.ncs-clustering.com/v1'
)

# Prepare your data
data = pd.DataFrame({
    'x': [1.5, 2.1, 3.4],
    'y': [2.3, 1.9, 4.1],
    'feature3': [0.8, 1.2, 2.1]
})

# Run clustering
try:
    result = client.cluster(
        algorithm='ncs',
        data=data.to_dict('records'),
        parameters={
            'neural_depth': 3,
            'learning_rate': 0.05
        }
    )
    
    print(f"Clusters found: {result['clusters']}")
    print(f"Processing time: {result['processing_time']}ms")
    print(f"Silhouette score: {result['metrics']['silhouette_score']}")
    
except Exception as error:
    print(f"Clustering failed: {error}")
curl -X POST https://api.ncs-clustering.com/v1/cluster \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "algorithm": "ncs",
    "data": [
      {"x": 1.5, "y": 2.3, "feature3": 0.8},
      {"x": 2.1, "y": 1.9, "feature3": 1.2},
      {"x": 3.4, "y": 4.1, "feature3": 2.1}
    ],
    "parameters": {
      "neural_depth": 3,
      "learning_rate": 0.05
    }
  }'

Authentication

The NCS-API uses API keys for authentication. Include your API key in the Authorization header of all requests:

Authorization: Bearer your-api-key
Security Note: Keep your API keys secure and never expose them in client-side code. Use environment variables in production.

Getting Your API Key

  1. Sign up for a free account at dashboard.ncs-api.com
  2. Navigate to the API Keys section
  3. Generate a new API key with appropriate permissions
  4. Copy and securely store your API key

Rate Limits

To ensure fair usage and optimal performance, the NCS-API implements rate limiting based on your subscription plan:

Plan Requests/Minute Data Points/Request Concurrent Requests
Free 60 1,000 2
Pro 300 10,000 10
Enterprise 1,000 100,000 50

Rate limit headers are included in all responses:

X-RateLimit-Limit: 300
X-RateLimit-Remaining: 299
X-RateLimit-Reset: 1640995200

Clustering Endpoints

POST /cluster

Perform clustering analysis on your dataset using the specified algorithm and parameters.

Request Parameters

Parameter Type Required Description
algorithm string required Clustering algorithm: kmeans, dbscan, hierarchical, ncs
data array required Array of data objects with numeric features
parameters object optional Algorithm-specific parameters (see algorithm sections)
preprocessing object optional Data preprocessing options

๐Ÿงช Try it out

NCS Neural Algorithm

Our proprietary Neural Clustering System (NCS) uses deep learning techniques to identify complex patterns and clusters in high-dimensional data.

Parameters

Parameter Type Default Description
neural_depth integer 3 Neural network depth (1-10)
learning_rate float 0.05 Learning rate for optimization (0.001-0.1)
max_clusters integer auto Maximum number of clusters to find
convergence_threshold float 0.0001 Convergence threshold for optimization
Best for: High-dimensional data, complex patterns, non-linear relationships, and datasets where traditional algorithms struggle.

JavaScript SDK

The official JavaScript/TypeScript SDK provides a convenient interface for integrating NCS-API into web and Node.js applications.

Installation

npm install @ncs-api/client

Basic Usage

import { NCSClient } from '@ncs-api/client';

const client = new NCSClient({
  apiKey: process.env.NCS_API_KEY,
  baseURL: 'https://api.ncs-clustering.com/v1',
  timeout: 30000
});

// Async/await syntax
try {
  const result = await client.cluster({
    algorithm: 'ncs',
    data: yourData,
    parameters: { neural_depth: 4 }
  });
  console.log(result);
} catch (error) {
  console.error('Error:', error.message);
}

// Promise syntax
client.cluster({
  algorithm: 'kmeans',
  data: yourData,
  parameters: { k: 3 }
})
.then(result => console.log(result))
.catch(error => console.error(error));

Real-time Streaming

// Subscribe to real-time clustering updates
const stream = client.createStream({
  algorithm: 'ncs',
  parameters: { neural_depth: 3 }
});

stream.on('data', (chunk) => {
  // Process incoming data point
  console.log('New data:', chunk);
});

stream.on('cluster_update', (clusters) => {
  // Handle cluster updates
  console.log('Updated clusters:', clusters);
});

stream.on('error', (error) => {
  console.error('Stream error:', error);
});

// Send data to stream
stream.write({ x: 1.5, y: 2.3, z: 0.8 });