This guide will walk you through installing the official JavaScript SDK and running your first scan. In just a few minutes, you’ll be able to easily use Copyleaks products directly from your JavaScript or TypeScript application. Before you start, ensure you have the following:

Get Started

1

Installation

First, install the official plagiarism-checker package from npm into your project.
npm i plagiarism-checker
2

Quick Example: Scan Text

The following example shows how to authenticate and submit a simple string of text for a plagiarism scan using the SDK’s data models.
Remember to replace the placeholder credentials and webhook URL with your actual values.
const { Copyleaks, CopyleaksFileSubmissionModel } = require('plagiarism-checker');

// --- Your Credentials ---
const EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
const KEY = 'YOUR_API_KEY';
const WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
// --------------------

async function main() {
  console.log('Authenticating...');
  const copyleaks = new Copyleaks();
  const authToken = await copyleaks.loginAsync(EMAIL_ADDRESS, KEY);
  console.log(' Login successful!');

  console.log('Submitting text for scanning...');
  const scanId = `${Date.now()}`; // Use a timestamp for a unique ID
  const textToScan = 'Hello world, this is a test.';
  const base64Content = Buffer.from(textToScan).toString('base64');
  
  const submission = new CopyleaksFileSubmissionModel(
    base64Content,
    'test.txt',
    {
      sandbox: true, // Turn on sandbox mode for testing
      webhooks: {
        status: WEBHOOK_URL
      }
    }
  );
  
  await copyleaks.submitFileAsync(authToken, scanId, submission);
  console.log(` Scan submitted successfully! Scan ID: ${scanId}`);
}

main().catch(err => console.error(err));
3

Understanding the Code

  1. Login: We authenticate with your email and API key to get a secure login token.
  2. Prepare Submission: We encode a string to Base64 and create a new CopyleaksFileSubmissionModel. This model is the recommended way to structure your submission data.
  3. Configure & Submit: We pass the submission model to submitFileAsync. The model itself contains the sandbox settings and the webhook URL where Copyleaks will send a notification when the scan is complete.

Next Steps

GitHub Repository

Check the official Copyleaks NodeJS SDK repository on GitHub for installation and usage details.

NPM Package

Install the official Copyleaks NodeJS package from NPM for easy integration.

Check for Plagiarism

Detect plagiarism in text documents using the Copyleaks API. Search billions of sources to find unoriginal content.

Detect AI-Generated Content

Detect AI-generated text via sync or async API calls. This guide covers sync detection, see the Authenticity API Guide for async.

Assess Grammar and Writing Quality

Get writing and grammar suggestions via API. Authenticate, submit text, and access full details in the docs.

Moderate Text

Scan and moderate text content for unsafe or policy-relevant material across 10+ categories.