The official Copyleaks JavaScript library.
Before you start, ensure you have the following:
- An active Copyleaks account. If you don’t have one, sign up for free.
- You can find your API key on the API Dashboard.
Once you have your account and API key:
Install the SDK:
Install using npm
npm i plagiarism-checker
To learn more about how to use Copyleaks API please check out our Documentation.
Here are some common usage examples for the Copyleaks SDK. You can also see a comprehensive code example in the index.js
file on our GitHub repository: index.js.
This example demonstrates how to log in to the Copyleaks API and obtain an authentication token.
const { Copyleaks } = 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!');
}
main();
For a detailed understanding of the authentication process, refer to the Copyleaks Login Endpoint Documentation.
This example shows how to prepare and submit raw text content for a plagiarism scan.
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() {
var submission = new CopyleaksFileSubmissionModel(
"SGVsbG8gV29ybGQ=",
"nodejs-sdk-demo.txt",
{
sandbox: true,
webhooks: {
status: `${WEBHOOK_URL}/submit-file-webhook/{STATUS}`,
},
}
);
copyleaks.submitFileAsync(authToken, Date.now() + 1, submission).then(
(res) => logSuccess("submitFileAsync", res),
(err) => {
logError("submitFileAsync", err);
}
);
}
main().catch(err => console.error(err));
For a full guide please refer to our step by step Guide
For a detailed understanding of the plagiarism detection process, refer to the Copyleaks Submit Endpoint Documentation
Use the AI detection client to determine if content was generated by artificial intelligence.
const { Copyleaks,CopyleaksNaturalLanguageSubmissionModel } = 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() {
const sampleText =
"Lions are social animals, living in groups called prides, typically consisting of several females, their offspring, and a few males. Female lions are the primary hunters, working together to catch prey. Lions are known for their strength, teamwork, and complex social structures.";
const submission = new CopyleaksNaturalLanguageSubmissionModel(sampleText);
submission.sandbox = true;
copyleaks.aiDetectionClient
.submitNaturalTextAsync(authToken, Date.now() + 1, submission)
.then((response) => {
logSuccess("TEST_submitAIDetectionNaturalLanguage", response);
})
.catch((error) => {
logError("TEST_submitAIDetectionNaturalLanguage", error);
});
}
main().catch(err => console.error(err));
For a full guide please refer to our step by step Guide
For a detailed understanding of the Ai detection process, refer to the Copyleaks detect natural language Endpoint Documentation
Get intelligent suggestions for improving grammar, spelling, style, and overall writing quality.
const { Copyleaks,CopyleaksWritingAssistantSubmissionModel } = 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() {
const sampleText =
"Lions are the only cat that live in groups, called pride. A prides typically consists of a few adult males, several feales, and their offspring. This social structure is essential for hunting and raising young cubs. Female lions, or lionesses are the primary hunters of the prid. They work together in cordinated groups to take down prey usually targeting large herbiores like zbras, wildebeest and buffalo. Their teamwork and strategy during hunts highlight the intelligence and coperation that are key to their survival.";
const submission = new CopyleaksWritingAssistantSubmissionModel(sampleText);
submission.sandbox = true;
copyleaks.writingAssistantClient
.submitTextAsync(authToken, Date.now() + 1, submission)
.then((response) => {
logSuccess("TEST_submitWritingAssistText", response);
})
.catch((error) => {
logError("TEST_submitWritingAssistText", error);
});
}
main().catch(err => console.error(err));
For a full guide please refer to our step by step Guide
For a detailed understanding of the Writing assistant process, refer to the Copyleaks writing feedback Endpoint Documentation
Scan and moderate text content for unsafe, inappropriate, or policy-violating material across various categories.
const { Copyleaks,CopyleaksWritingAssistantSubmissionModel } = 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() {
var labelsArray=[
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.ADULT_V1),
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.TOXIC_V1),
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.VIOLENT_V1),
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.PROFANITY_V1),
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.SELF_HARM_V1),
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.HARASSMENT_V1),
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.HATE_SPEECH_V1),
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.DRUGS_V1),
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.FIREARMS_V1),
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.CYBERSECURITY_V1)
];
const model = new CopyleaksTextModerationRequestModel({
text: "This is some text to scan.",
sandbox: true,
language: CopyleaksTextModerationLanguages.ENGLISH,
labels:labelsArray
});
copyleaks.textModerationClient.submitTextAsync(authToken, Date.now() + 1, model)
.then(response => {
logSuccess('TEST_submitTextModerationText', JSON.stringify(response, null, 2));
})
.catch(error => {
logError('TEST_submitTextModerationText', error);
});
}
main().catch(err => console.error(err));
For a full guide please refer to our step by step Guide
For a detailed understanding of the Text moderation process, refer to the Copyleaks text moderation Endpoint Documentation
- Copyleaks API Dashboard: Manage your API keys, monitor usage, and view analytics from your personalized dashboard. Access Dashboard
- Copyleaks SDK Documentation: Explore comprehensive guides, API references, and code examples for seamless integration. Read Documentation
- If you need assistance, please contact Copyleaks Support via our support portal: Contact Copyleaks Support.
- To arrange a product demonstration, book a demo here: Booking Link.