The official Copyleaks Ruby 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 RubyGems
gem install 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 demo.rb
file on our GitHub repository: demo.rb.
This example demonstrates how to log in to the Copyleaks API and obtain an authentication token.
require 'copyleaks'
require 'base64'
# --- Your Credentials ---
USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
USER_API_KEY = 'YOUR_API_KEY'
WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}'
# --------------------
begin
# Log in to the Copyleaks API
puts "Authenticating..."
copyleaks = Copyleaks::API.new
auth_token = copyleaks.login(USER_EMAIL, USER_API_KEY)
puts "✅ Logged in successfully!"
end
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.
require 'copyleaks'
require 'base64'
# --- Your Credentials ---
USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
USER_API_KEY = 'YOUR_API_KEY'
WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}'
# --------------------
begin
scanId = DateTime.now.strftime('%Q').to_s
submisson = Copyleaks::CopyleaksFileSubmissionModel.new(
'aGVsbG8gd29ybGQ=',
'ruby.txt',
Copyleaks::SubmissionProperties.new(
Copyleaks::SubmissionWebhooks.new("#{WEBHOOK_URL}/url-webhook/scan/#{scanId}/{STATUS}","#{WEBHOOK_URL}/url-webhook/new-result"),
true,
'developer_payloads_test',
true,
60,
1,
true,
Copyleaks::SubmissionActions::SCAN,
Copyleaks::SubmissionAuthor.new('Author_name'),
Copyleaks::SubmissionFilter.new(true, true, true),
Copyleaks::SubmissionScanning.new(true, nil, nil, Copyleaks::SubmissionScanningCopyleaksDB.new(true, true)),
Copyleaks::SubmissionIndexing.new([Copyleaks::SubmissionRepository.new('repo-1')]),
Copyleaks::SubmissionExclude.new(true, true, true, true, true),
Copyleaks::SubmissionPDF.new(true, 'pdf-title', BASE64_LOGO, false),
Copyleaks::SubmissionSensitiveData.new(false)
)
)
@copyleaks.submit_file(_authToken, scanId, submisson)
end
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.
require 'copyleaks'
require 'base64'
# --- Your Credentials ---
USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
USER_API_KEY = 'YOUR_API_KEY'
WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}'
# --------------------
begin
scanId = DateTime.now.strftime('%Q').to_s
text = "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."
submission = Copyleaks::NaturalLanguageSubmissionModel.new(
text,
)
submission.sandbox = true
res = @copyleaks.ai_detection_client.submit_natural_language(_authToken, scanId, submission)
end
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.
require 'copyleaks'
require 'base64'
# --- Your Credentials ---
USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
USER_API_KEY = 'YOUR_API_KEY'
WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}'
# --------------------
begin
text = "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."
scanId = DateTime.now.strftime('%Q').to_s
score_weights = Copyleaks::ScoreWeights.new(0.1, 0.2, 0.3, 0.4)
submission = Copyleaks::WritingAssistantSubmissionModel.new(
text,
)
submission.sandbox = true
submission.score = score_weights
res = @copyleaks.writing_assistant_client.submit_text(_authToken, scanId, submission)
end
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.
require 'copyleaks'
require 'base64'
# --- Your Credentials ---
USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
USER_API_KEY = 'YOUR_API_KEY'
WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}'
# --------------------
begin
scanId = DateTime.now.strftime('%Q').to_s
labelsArray=[
Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::ADULT_V1),
Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::TOXIC_V1),
Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::VIOLENT_V1),
Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::PROFANITY_V1),
Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::SELF_HARM_V1),
Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::HARASSMENT_V1),
Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::HATE_SPEECH_V1),
Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::DRUGS_V1),
Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::FIREARMS_V1),
Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::CYBERSECURITY_V1)
]
text_moderation_request = Copyleaks::CopyleaksTextModerationRequestModel.new(
text: "This is some text to scan.",
sandbox: true,
language: Copyleaks::CopyleaksTextModerationLanguages::ENGLISH,
labels: labelsArray
)
res = @copyleaks.text_moderation_client.submit_text(_authToken, scanId, text_moderation_request)
textModerationResponse = Copyleaks::CopyleaksTextModerationResponseModel.new(
moderations: res['moderations'],
legend: res['legend'],
scanned_document: res['scannedDocument'])
end
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.