API

Server API

Use jscpd-server for remote duplication detection.

Installation

npm install -g jscpd-server

Starting the Server

jscpd-server

The server starts on http://localhost:3000 by default.

API Endpoints

Check for Duplications

POST /api/check

curl -X POST http://localhost:3000/api/check \
  -H "Content-Type: application/json" \
  -d '{
    "code": "console.log(\"hello\");\nconsole.log(\"world\");",
    "format": "javascript"
  }'

Response

{
  "clones": [],
  "statistics": {
    "lines": 2,
    "tokens": 10,
    "duplicatedLines": 0,
    "percentage": 0
  }
}

Configuration

# Custom port
jscpd-server --port 8080

# Custom options
jscpd-server --min-lines 3 --min-tokens 30

Use Cases

  • IDE plugins
  • Code review tools
  • CI/CD pipelines
  • Online code analysis services