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:
- Don't have an account? Sign up for free
- You can find your API key on the API Dashboard
🚀 Get Started
Section titled “🚀 Get Started”-
Installation
First, install the official
plagiarism-checker
package from npm into your project.Terminal window npm i plagiarism-checker -
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 IDconst 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 testingwebhooks: {status: WEBHOOK_URL}});await copyleaks.submitFileAsync(authToken, scanId, submission);console.log(`🚀 Scan submitted successfully! Scan ID: ${scanId}`);}main().catch(err => console.error(err));scan.ts import {Copyleaks,CopyleaksFileSubmissionModel,type CopyleaksAuthToken} from '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: CopyleaksAuthToken = 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 IDconst 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 testingwebhooks: {status: WEBHOOK_URL}});await copyleaks.submitFileAsync(authToken, scanId, submission);console.log(`🚀 Scan submitted successfully! Scan ID: ${scanId}`);}main().catch(err => console.error(err)); -
Understanding the Code
- Login: We authenticate with your email and API key to get a secure login token.
- Prepare Submission: We encode a string to Base64 and create a new
CopyleaksFileSubmissionModel
. This model is the recommended way to structure your submission data. - 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
Section titled “🗺️ Next Steps”Now that you’ve submitted your first scan, here are some recommended steps:
Package Source
Section titled “Package Source” 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.