Skip to content
Official SDKs

JavaScript Quickstart Guide

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 begin

In order to start integrating Copyleaks API, you'll need an account and an API key:

  1. Installation

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

    Terminal window
    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.

    scan.js
    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.

Now that you’ve submitted your first scan, here are some recommended steps: