Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
162 lines (139 sloc) 6.29 KB

Copyleaks API C# SDK

Copyleaks SDK is a simple framework that allows you to perform plagiarism scans and track content distribution around the web, using Copyleaks cloud.

With Copyleaks SDK you can submit for scan:

  • Webpages
  • Local files - pdf, doc, docx, rtf and more (see full list)
  • Free text
  • OCR (Optical Character Recognition) - scanning pictures containing textual content (see full list)
Instructions for using the SDK are below. For a quick example demonstrating the SDK capabilities just look at the code examples under “examples”. You can also watch the following video demonstrating how to easily integrate with the API -


You can integrate with the Copyleaks SDK in one of two ways:

  1. Download the code from here, compile it and add reference to the assembly.
  2. Add CopyleaksAPI NuGet by running the following command in the Package Manager Console
  3. Install-Package CopyleaksAPI

Signing Up and Getting Your API Key

To use the Copyleaks API you need to be a registered user. Signing up is quick and free of charge.

Signup to Copyleaks and confirm your account by clicking the link on the confirmation email. Generate your personal API key on your dashboard (Businesses dashboard/Academic dashboard/Websites dashboard) under 'Access Keys'.

For more information check out our API guide.


This code will show you how to scan files or URLs for plagiarism:

using System;
using System.Threading;
using Copyleaks.SDK.API;
using Copyleaks.SDK.API.Exceptions;
using Copyleaks.SDK.API.Models;

private static void Scan(string email, string apiKey)
	CopyleaksCloud copyleaks = new CopyleaksCloud(eProduct.Businesses);
	CopyleaksProcess createdProcess;
	ProcessOptions scanOptions = new ProcessOptions();
	scanOptions.SandboxMode = true; // Sandbox mode --> Read more
	ResultRecord[] results;
		#region Login to Copyleaks cloud
		Console.Write("Login to Copyleaks cloud...");
		copyleaks.Login(email, apiKey);
		#region Checking account balance
		Console.Write("Checking account balance...");
		uint creditsBalance = copyleaks.Credits;
		Console.WriteLine("Done ({0} credits)!", creditsBalance);
		if (!scanOptions.SandboxMode && creditsBalance == 0)
			Console.WriteLine("ERROR: You do not have enough credits to complete this scan. Your balance is {0}).", creditsBalance);
		#region callbacks
		// Add a URL address to get notified, using callbacks, once the scan results are ready. 
		//Read more
		//scanOptions.HttpCallback = new Uri("{PID}");
		//scanOptions.InProgressResultsCallback = new Uri("{PID}");
		#region Submitting a new scan process to the server
		// Insert here the URL that you'd like to scan for plagiarism
		createdProcess = copyleaks.CreateByUrl(new Uri(""), scanOptions);
		// Insert here the file that you'd like to scan for plagiarism
		//createdProcess = copyleaks.CreateByFile(new FileInfo("C:\FiletoScan.pdf"), scanOptions);
		Console.WriteLine("Done (PID={0})!", createdProcess.PID);
		#region Waiting for server's process completion
		// Use this if you are not using callback
		Console.Write("Scanning... ");
		ushort currentProgress;
		while (!createdProcess.IsCompleted(out currentProgress))
			Console.WriteLine(currentProgress + "%");
		#region Processing finished. Getting results
		results = createdProcess.GetResults();
		if (results.Length == 0)
			Console.WriteLine("No results.");
			for (int i = 0; i < results.Length; ++i)
				if (results[i].URL != null)
					Console.WriteLine("Url: {0}", results[i].URL);
				Console.WriteLine("Information: {0} copied words ({1}%)", results[i].NumberOfCopiedWords, results[i].Percents);
				Console.WriteLine("Comparison report: {0}", results[i].ComparisonReport);
				Console.WriteLine("Title: {0}", results[i].Title);
				Console.WriteLine("Introduction: {0}", results[i].Introduction);
				Console.WriteLine("Embeded comparison: {0}", results[i].EmbededComparison);
	catch (UnauthorizedAccessException)
		Console.WriteLine("Authentication with the server failed!");
		Console.WriteLine("Possible reasons:");
		Console.WriteLine("* You did not log in to Copyleaks cloud");
		Console.WriteLine("* Your login token has expired");
	catch (CommandFailedException theError)
		Console.WriteLine("*** Error {0}:", theError.CopyleaksErrorCode);
		Console.WriteLine("{0}", theError.Message);


Referenced Assemblies:

Read More