SDKs overview
Uploadcare offers a suite of Software Development Kits (SDKs) and community-contributed libraries designed to facilitate integration with its file management and media processing platform. These SDKs abstract the underlying REST API, enabling developers to incorporate features like file uploading, image optimization, and dynamic media transformations directly within their applications using familiar programming languages and frameworks. The official SDKs are maintained by Uploadcare, while community libraries extend support to additional languages or provide specialized integrations.
The primary goal of these SDKs is to reduce development time and complexity when working with user-generated content (UGC) or any file-based assets. They provide structured methods for common operations, such as initializing the file uploader widget, managing file uploads programmatically, applying image transformations, and retrieving file information. For example, the JavaScript SDK provides an Uploadcare File Uploader widget that can be embedded directly into web applications, handling UI, drag-and-drop functionality, and progress indicators.
Uploadcare's approach to SDK development emphasizes ease of use across various development stacks, including modern frontend frameworks and popular backend languages. Developers can choose the SDK that best fits their project's technology stack, ensuring compatibility and leveraging language-specific idioms. Comprehensive documentation for each SDK is available, detailing installation, configuration, and usage examples for Uploadcare API endpoints.
Official SDKs by language
Uploadcare provides official SDKs for a range of popular programming languages and frameworks. These SDKs are actively maintained and offer the most stable and feature-rich integration options. They typically include functionalities for direct file uploads, widget integration, file processing operations, and access to CDN features. The table below outlines the key official SDKs, their package names, installation commands, and general maturity level.
| Language / Framework | Package Name | Installation Command | Maturity |
|---|---|---|---|
| JavaScript (Browser) | uploadcare-widget |
npm install uploadcare-widget or via CDN |
Stable |
| React | react-uploadcare-widget |
npm install react-uploadcare-widget |
Stable |
| Angular | ngx-uploadcare-widget |
npm install ngx-uploadcare-widget |
Stable |
| Vue | vue-uploadcare-widget |
npm install vue-uploadcare-widget |
Stable |
| Node.js | uploadcare |
npm install uploadcare |
Stable |
| PHP | uploadcare/uploadcare-php |
composer require uploadcare/uploadcare-php |
Stable |
| Python | pyuploadcare |
pip install pyuploadcare |
Stable |
| Ruby | uploadcare-ruby |
Add gem 'uploadcare-ruby' to Gemfile |
Stable |
| Java | uploadcare-java |
Via Maven/Gradle dependency | Stable |
| Go | github.com/uploadcare/uploadcare-go |
go get github.com/uploadcare/uploadcare-go |
Stable |
| .NET | Uploadcare |
Install-Package Uploadcare (NuGet) |
Stable |
Installation
Installation methods for Uploadcare SDKs vary by programming language and ecosystem. Most modern SDKs are distributed via package managers specific to their language, such as npm for JavaScript and Node.js, Composer for PHP, pip for Python, and RubyGems for Ruby. For Java and .NET, dependency management systems like Maven/Gradle and NuGet are used. Frontend frameworks like React, Angular, and Vue often have dedicated wrapper libraries that build upon the core JavaScript widget.
JavaScript (Browser Widget)
For web applications, the Uploadcare Widget can be installed via npm or by including a script tag directly:
npm install uploadcare-widget
Alternatively, for a quick start, you can include the widget via a CDN:
<script src="https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js"></script>
Python
The Python SDK, pyuploadcare, is installed using pip:
pip install pyuploadcare
After installation, you typically configure it with your Uploadcare public and secret keys, as detailed in the Python SDK integration guide.
PHP
The PHP SDK is installed via Composer:
composer require uploadcare/uploadcare-php
Configuration involves setting your API keys, often done in an application's environment configuration file or directly when initializing the client object.
Node.js
The Node.js SDK is available via npm:
npm install uploadcare
This SDK is suitable for backend operations, such as managing files, retrieving file info, and performing server-side transformations.
Other Languages
For other languages like Ruby, Java, Go, and .NET, follow the specific instructions on the Uploadcare documentation portal for adding the respective package or library to your project's dependencies. For instance, Ruby applications add gem 'uploadcare-ruby' to their Gemfile and run bundle install. Java projects might add a dependency to their pom.xml (Maven) or build.gradle (Gradle) file.
Quickstart example
A common use case for Uploadcare SDKs is integrating the file uploader widget into a web application. The following JavaScript example demonstrates how to include and initialize the Uploadcare widget to allow users to upload files.
JavaScript Widget Example
First, ensure the Uploadcare widget script is loaded in your HTML, either via CDN or your build process:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Uploadcare Widget Example</title>
<script src="https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js"></script>
<script>
// Configure Uploadcare with your public key
UPLOADCARE_PUBLIC_KEY = 'YOUR_PUBLIC_KEY'; // Replace with your actual public key
</script>
</head>
<body>
<h1>Upload a File</h1>
<!-- The input field where the widget will attach -->
<input type="hidden" role="uploadcare-uploader" name="my_file" id="my-file-input" data-multiple="true" />
<div id="uploaded-file-info"></div>
<script>
const input = document.getElementById('my-file-input');
input.addEventListener('change', (event) => {
const file = event.target.uploadcare.file;
if (file) {
file.done((fileInfo) => {
const infoDiv = document.getElementById('uploaded-file-info');
infoDiv.innerHTML = `<p>Uploaded: <a href="${fileInfo.cdnUrl}" target="_blank">${fileInfo.name || fileInfo.uuid}</a></p>
<img src="${fileInfo.cdnUrl}-/scale_crop/200x200/" alt="Thumbnail" style="max-width: 200px; max-height: 200px;" />`;
console.log('File uploaded:', fileInfo);
});
}
});
</script>
</body>
</html>
In this example, the UPLOADCARE_PUBLIC_KEY must be replaced with your actual Uploadcare public key, obtainable from your Uploadcare dashboard. The role="uploadcare-uploader" attribute automatically initializes the widget on the input field. The change event listener then captures the uploaded file information and displays a link and a dynamically transformed thumbnail.
Python SDK Example
For backend operations, the Python SDK can be used to manage files programmatically:
import uploadcare
# Configure with your Uploadcare keys
# Replace with your actual public and secret keys
api = uploadcare.api.Uploadcare(public_key='YOUR_PUBLIC_KEY', secret_key='YOUR_SECRET_KEY')
# Example: Get file information by UUID
file_uuid = 'a1b2c3d4-e5f6-7890-1234-567890abcdef' # Replace with an actual file UUID
try:
file_info = api.file(file_uuid)
print(f"File Name: {file_info.filename}")
print(f"File Size: {file_info.size} bytes")
print(f"CDN URL: {file_info.cdn_url}")
print(f"Image Info: {file_info.image_info}")
except uploadcare.exceptions.UploadcareException as e:
print(f"Error retrieving file info: {e}")
# Example: Upload a local file
try:
with open('local_image.jpg', 'rb') as f:
uploaded_file = api.upload(f)
print(f"Uploaded file UUID: {uploaded_file.uuid}")
print(f"Uploaded file CDN URL: {uploaded_file.cdn_url}")
except FileNotFoundError:
print("local_image.jpg not found. Please create one for testing.")
except uploadcare.exceptions.UploadcareException as e:
print(f"Error uploading file: {e}")
This Python snippet demonstrates how to initialize the Uploadcare client with API keys and then perform two common operations: retrieving detailed information about an existing file using its UUID, and uploading a local file programmatically. Note that YOUR_PUBLIC_KEY and YOUR_SECRET_KEY must be replaced with valid credentials.
Community libraries
Beyond the officially supported SDKs, the Uploadcare ecosystem benefits from community-driven libraries and integrations. These resources often provide support for niche frameworks, specific application architectures, or experimental features not yet incorporated into official releases. While not directly maintained by Uploadcare, they can offer valuable tools for developers working in diverse environments.
Examples of community contributions might include:
- Framework-specific plugins: Libraries that offer tighter integration with less common web frameworks or content management systems (CMS) beyond the official React, Angular, and Vue support.
- Specialized tools: Utilities for specific tasks, such as bulk import/export scripts, advanced image manipulation pre-processors, or integrations with third-party services.
- Language wrappers: SDKs for languages where an official Uploadcare library does not yet exist, allowing developers to interact with the API using their preferred language.
Developers interested in community libraries should consult the Uploadcare integrations page or search on platforms like GitHub and package repositories (e.g., npm, PyPI, Packagist) for uploadcare-related projects. When using community-contributed code, it is advisable to review its maintenance status, documentation, and community support to ensure it meets project requirements and security standards. The Open Source Initiative provides guidance on evaluating open-source projects, which can be useful when considering community libraries.