SDKs overview

Cloudinary offers a suite of Software Development Kits (SDKs) designed to facilitate interaction with its media management and delivery platform. These SDKs abstract the underlying RESTful API, enabling developers to integrate image and video functionalities directly into their applications using familiar programming languages and frameworks. The SDKs cover common operations such as uploading assets, applying complex transformations (e.g., resizing, cropping, effects), optimizing delivery, and managing digital assets programmatically. The availability of SDKs for multiple environments, including server-side languages, front-end JavaScript frameworks, and mobile platforms, aims to support diverse application architectures and development workflows Cloudinary SDK documentation.

The core functionality provided by the SDKs includes:

  • Asset Uploads: Programmatic uploading of images, videos, and other raw files to Cloudinary. This often includes features for direct browser uploads, signed uploads, and client-side resizing before upload.
  • Transformations: Applying a range of image and video transformations on the fly, such as resizing, cropping, rotating, adding overlays, watermarks, and various visual effects. These transformations are dynamically generated and delivered via CDN.
  • URL Generation: Constructing optimized and transformed media URLs that reference assets stored on Cloudinary. The SDKs assist in building complex transformation chains into a single URL.
  • Asset Management: Features for listing, searching, deleting, and updating metadata for assets stored in Cloudinary's Digital Asset Management (DAM) system.
  • Authentication and Security: Handling API authentication securely, often through API keys and secrets, and providing methods for generating signed URLs or secure upload signatures.

While SDKs streamline API interactions, developers can also directly interact with the Cloudinary REST API reference using HTTP clients if a specific language or framework is not covered by an official SDK, or for highly customized integration needs. The API itself is well-documented, adhering to common REST principles.

Official SDKs by language

Cloudinary provides official SDKs for a broad range of programming languages and development environments, ensuring developers can integrate media management capabilities into various application types.

Language/Framework Package Name Maturity Notes
Node.js cloudinary Stable Server-side library for Node.js applications.
Python cloudinary Stable Python library for web frameworks like Django and Flask.
Ruby cloudinary Stable Ruby gem for Rails and other Ruby applications.
PHP cloudinary/cloudinary_php Stable PHP library compatible with frameworks like Laravel and Symfony.
.NET CloudinaryDotNet Stable .NET library for C# and other .NET languages.
Java cloudinary Stable Java library supporting Maven and Gradle projects.
Go github.com/cloudinary/cloudinary-go/v2 Stable Go module for Go applications.
Dart (Flutter) cloudinary_url_gen Stable Dart package specifically for URL generation in Flutter.
React @cloudinary/react Stable React SDK with components for image and video display.
Angular @cloudinary/angular Stable Angular SDK with directives for media management.
Vue.js @cloudinary/vue Stable Vue.js SDK with components for media integration.
Android com.cloudinary:cloudinary-android Stable Native Android SDK for mobile applications.
iOS Cloudinary/Cloudinary (CocoaPods) Stable Native iOS SDK for Swift/Objective-C applications.

Installation

Installation of Cloudinary SDKs typically involves using the respective language's package manager. Configuration usually requires setting your cloud_name, api_key, and api_secret, which are available in your Cloudinary dashboard Cloudinary integration guide. It's recommended to store API secrets securely using environment variables or a configuration management system, rather than hardcoding them directly into the application code.

Node.js

npm install cloudinary

Python

pip install cloudinary

Ruby

gem install cloudinary

PHP

composer require cloudinary/cloudinary_php

.NET

Install-Package CloudinaryDotNet

Java

Add the following dependency to your pom.xml (for Maven):

<dependency>
    <groupId>com.cloudinary</groupId>
    <artifactId>cloudinary-core</artifactId>
    <version>1.37.0</version>
</dependency>
<dependency>
    <groupId>com.cloudinary</groupId>
    <artifactId>cloudinary-http44</artifactId>
    <version>1.37.0</version>
</dependency>

Go

go get github.com/cloudinary/cloudinary-go/v2

Dart (Flutter)

Add to your pubspec.yaml:

dependencies:
  cloudinary_url_gen: ^0.1.0

Quickstart example

This quickstart demonstrates uploading an image and generating a transformed URL using the Node.js SDK. Similar patterns apply across other SDKs, with syntax variations specific to each language.

Configuration

First, configure your Cloudinary credentials. It is a recommended practice to use environment variables for sensitive information like API keys and secrets.

// In a Node.js environment, using dotenv for example
require('dotenv').config();

const cloudinary = require('cloudinary').v2;

cloudinary.config({
  cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
  api_key: process.env.CLOUDINARY_API_KEY,
  api_secret: process.env.CLOUDINARY_API_SECRET,
  secure: true
});

console.log('Cloudinary configuration loaded successfully.');

Image Upload

The following example uploads a local image file and logs the returned asset information, including its URL.

const uploadImage = async () => {
  try {
    const uploadResult = await cloudinary.uploader.upload("https://upload.wikimedia.org/wikipedia/commons/a/af/Arnold_Schwarzenegger_at_the_2008_Olympia_%28cropped%29.jpg", {
      folder: "apispine_sdk_examples",
      public_id: "schwarzenegger_wiki_example"
    });
    console.log("Upload successful:", uploadResult);
    return uploadResult.public_id;
  } catch (error) {
    console.error("Upload failed:", error);
  }
};

uploadImage().then(publicId => {
  if (publicId) {
    console.log(`Uploaded image public ID: ${publicId}`);
  }
});

Generate Transformed URL

After uploading, you can generate URLs for the image with various transformations. This example generates a URL for a cropped image.

const generateTransformedUrl = (publicId) => {
  if (!publicId) {
    console.log("Public ID not available for URL generation.");
    return;
  }
  const imageUrl = cloudinary.url(publicId, {
    width: 200,
    height: 200,
    crop: "thumb",
    gravity: "face",
    effect: "grayscale",
    quality: "auto:eco"
  });
  console.log("Transformed image URL:", imageUrl);
  return imageUrl;
};

// Assuming 'schwarzenegger_wiki_example' was the public ID from the upload
generateTransformedUrl("apispine_sdk_examples/schwarzenegger_wiki_example");

The resulting URL would dynamically serve the image after applying the specified transformations (thumbnail crop, grayscale effect, and automatic eco quality optimization). These transformations are performed by Cloudinary's servers at the time of the request.

For more detailed examples across different languages and specific use cases, refer to the Cloudinary integration documentation. Developers can also consult general best practices for API key management, such as those outlined by Microsoft's guidance on API key security, to further secure their Cloudinary integrations.

Community libraries

While Cloudinary provides a comprehensive set of official SDKs, the developer community often contributes additional libraries and tools that extend functionality or provide integrations with niche frameworks and platforms. These community-driven projects can offer specialized utilities, convenience wrappers, or integrations for languages and environments not officially supported.

Examples of areas where community libraries might emerge include:

  • Specific CMS Integrations: Modules or plugins for content management systems (CMS) like WordPress, Drupal, or Joomla that offer deeper integration with Cloudinary's DAM or media delivery features beyond official plugins.
  • Niche Framework Adapters: Libraries that adapt Cloudinary SDKs to specific, less common web frameworks or backend environments.
  • CLI Tools: Command-line interface tools developed by the community for managing Cloudinary assets from the terminal, potentially offering features beyond the official CLI.
  • Custom Upload Widgets: Advanced front-end upload widgets or components built for specific UI libraries that offer a tailored user experience for direct uploads.

Before adopting a community library, it is advisable to assess its active maintenance, community support, documentation quality, and security practices. Official Cloudinary channels, such as forums or GitHub repositories, may occasionally highlight notable community contributions. Always prioritize official SDKs for critical production environments due to their direct support from Cloudinary and adherence to API changes.