CloudConvert.API 1.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CloudConvert.API --version 1.4.0
                    
NuGet\Install-Package CloudConvert.API -Version 1.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CloudConvert.API" Version="1.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CloudConvert.API" Version="1.4.0" />
                    
Directory.Packages.props
<PackageReference Include="CloudConvert.API" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CloudConvert.API --version 1.4.0
                    
#r "nuget: CloudConvert.API, 1.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CloudConvert.API@1.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CloudConvert.API&version=1.4.0
                    
Install as a Cake Addin
#tool nuget:?package=CloudConvert.API&version=1.4.0
                    
Install as a Cake Tool

cloudconvert-dotnet

.NET Tests Nuget

This is the official .net SDK v1 for the CloudConvert API v2.

Installation

PM> Install-Package CloudConvert.API

or

dotnet add package CloudConvert.API

Creating Jobs

using CloudConvert.API;
using CloudConvert.API.Models.ExportOperations;
using CloudConvert.API.Models.ImportOperations;
using CloudConvert.API.Models.JobModels;
using CloudConvert.API.Models.TaskOperations;

var _cloudConvert = new CloudConvertAPI("api_key");

var job = await _cloudConvert.CreateJobAsync(new JobCreateRequest
      {
        Tasks = new
        {
          import_example_1 = new ImportUploadCreateRequest(),
          convert = new ConvertCreateRequest
          {
            Input = "import_example_1",
            Input_Format = "pdf",
            Output_Format = "docx"
          },
          export = new ExportUrlCreateRequest
          {
            Input = "convert",
            Archive_Multiple_Files = true
          }
        },
        Tag = "Test"
      });

You can use the CloudConvert Job Builder to see the available options for the various task types.

Downloading Files

CloudConvert can generate public URLs for using export/url tasks. You can use these URLs to download output files.

var job = await _cloudConvertAPI.WaitJobAsync(job.Data.Id); // Wait for job completion

// download export file

var exportTask = job.Data.Tasks.FirstOrDefault(t => t.Name == "export_it");

var fileExport = exportTask.Result.Files.FirstOrDefault();

using (var client = new WebClient()) client.DownloadFile(fileExport.Url, fileExport.Filename);

Uploading Files

Uploads to CloudConvert are done via import/upload tasks (see the docs). This SDK offers a convenient upload method.

First create the upload job with CreateJobAsync:

var job = await _cloudConvertAPI.CreateJobAsync(new JobCreateRequest
      {
            Tasks = new
            {
            upload_my_file = new ImportUploadCreateRequest()
            // ...
            }
      });

var uploadTask = job.Data.Tasks.FirstOrDefault(t => t.Name == "upload_my_file");

Then upload the file the file with UploadAsync. This can be done two ways:

  1. Upload using a Stream
    The file will be opened and send in chunks to CloudConvert.

    Note The stream will not be disposed. Make sure to dispose the stream with stream.Dispose() or by using the using-statement as shown in the following example.

    string path = @"TestFiles/test.pdf";
    string fileName = "test.pdf";
    
    using (System.IO.Stream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
    {
          await _cloudConvertAPI.UploadAsync(uploadTask.Result.Form.Url.ToString(), stream, fileName, uploadTask.Result.Form.Parameters);
    }
    
  2. Upload using a byte-array (byte[])
    The entire file will be load into memory and send to CloudConvert.

    string path = @"TestFiles/test.pdf";
    byte[] file = await File.ReadAllBytesAsync(path);
    string fileName = "test.pdf";
    
    await _cloudConvertAPI.UploadAsync(uploadTask.Result.Form.Url.ToString(), file, fileName, uploadTask.Result.Form.Parameters);
    

Conversion Specific Options

You can pass any custom options to the task payload via the special Options property:

var task = new ConvertCreateRequest
          {
            Input = "import_example_1",
            Input_Format = "pdf",
            Output_Format = "jpg",
            Options = new Dictionary<string, object> {
              { "width": 800 },
              { "height": 600 },
              { "fit": "max" }
            }
          }

You can use the Job Builder to see the available options.

Webhook Signing

The .net SDK allows to verify webhook requests received from CloudConvert.

var payloadString = "..."; // The JSON string from the raw request body.
var signature = "..."; // The value of the "CloudConvert-Signature" header.
var signingSecret = "..."; // You can find it in your webhook settings.

var isValid = _cloudConvertAPI.ValidateWebhookSignatures(payloadString, signature, signingSecret);
// returns true or false

Signed URLs

Signed URLs allow converting files on demand only using URL query parameters. The .NET SDK allows to generate such URLs. Therefore, you need to obtain a signed URL base and a signing secret on the CloudConvert Dashboard.

var signedUrlBase = 'https://s.cloudconvert.com/...'; // You can find it in your signed URL settings.
var signingSecret = '...'; // You can find it in your signed URL settings.
var cacheKey = 'cache-key'; // Allows caching of the result file for 24h

var job = new JobCreateRequest
      {
        Tasks = new
        {
          import_example_1 = new ImportUploadCreateRequest(),
          convert = new ConvertCreateRequest
          {
            Input = "import_example_1",
            Input_Format = "pdf",
            Output_Format = "docx"
          },
          export = new ExportUrlCreateRequest
          {
            Input = "convert"
          }
        },
};

string signedUrl = _cloudConvertAPI.CreateSignedUrl(baseUrl, signingSecret, job, cacheKey)
// returns the signed URL

Using the Sandbox

You can use the Sandbox to avoid consuming your quota while testing your application. The .net SDK allows you to do that.

// Pass `true` to the constructor
var _cloudConvert = new CloudConvertAPI("api_key", true);

Tests

dotnet test

Integration Tests

By default, this runs the integration tests against the Sandbox API with an official CloudConvert account. If you would like to use your own account, you can set your API key. In this case you need to whitelist the following MD5 hashes for Sandbox API (using the CloudConvert dashboard).

53d6fe6b688c31c565907c81de625046  input.pdf
99d4c165f77af02015aa647770286cf9  input.png

Resources

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.1 13,878 1/16/2026
1.4.0 82,736 3/18/2025
1.3.0 13,486 2/19/2025
1.2.0 230,764 1/2/2023
1.1.3 2,025 12/14/2022
1.1.2 34,479 10/28/2022
1.1.1 62,564 5/20/2022
1.1.0 83,895 3/30/2022
1.0.2 49,477 5/27/2021
1.0.1 1,808 4/19/2021
1.0.0 4,450 3/2/2021