SDKs overview

Storj offers a suite of Software Development Kits (SDKs) and client libraries designed to facilitate programmatic interaction with its decentralized cloud storage network. These tools allow developers to integrate storage, retrieval, and management of objects into their applications without directly managing the underlying decentralized infrastructure. The primary interface for most developers is through the Libuplink client library, which directly communicates with the Storj network. Additionally, Storj provides an S3-compatible Gateway, enabling applications to use existing Amazon S3 client libraries and tools to interact with Storj, thereby supporting a broader range of development environments and existing workflows.

The official SDKs are provided for several popular programming languages, ensuring broad accessibility for developers. These libraries encapsulate the complexities of connecting to the decentralized network, segmenting and encrypting data, and managing object lifecycle. Alongside the official offerings, community-contributed libraries and integrations further extend the ecosystem.

Developers typically choose between direct integration using a Libuplink-based SDK for optimal performance and direct control over network interactions, or leveraging the S3-compatible Gateway for simpler integration with existing S3-aware applications and tools. For command-line operations and scripting, the Uplink CLI provides similar functionality to the SDKs.

Official SDKs by language

Storj maintains official client libraries across multiple programming languages, built on the core libuplink functionality. These SDKs are designed to provide a native development experience for each language, abstracting the complexities of interacting with the decentralized network.

Language Package/Module Installation Command Maturity
Go storj.io/uplink go get storj.io/uplink Stable
Node.js @storj/uplink npm install @storj/uplink Stable
Python uplink-python pip install uplink-python Stable
Java io.storj:storj_uplink Add to pom.xml (Maven) or build.gradle (Gradle) Stable
Rust uplink-rust cargo add uplink-rust Stable
C# Storj.SDK dotnet add package Storj.SDK Stable

Each SDK provides methods for creating buckets, uploading and downloading objects, listing objects, and managing access permissions (called "access grants" in Storj terminology). Detailed API references and usage examples for each language are available in the Storj API Reference documentation.

Installation

Installation procedures vary by programming language and package manager. The following provides general instructions for each officially supported SDK. Prior to using any SDK, developers need to obtain an Access Grant, which contains encrypted API keys and network information, often generated via the Storj Satellites or the Uplink CLI.

Go

To install the Go SDK, use the Go module system:

go get storj.io/uplink

Ensure your project is initialized with go mod init.

Node.js

For Node.js projects, install the @storj/uplink package via npm or yarn:

npm install @storj/uplink
# or
yarn add @storj/uplink

Python

The Python SDK is available through pip:

pip install uplink-python

Java

For Java projects, add the Storj Uplink dependency to your build configuration. For Maven:

<dependencies>
    <dependency>
        <groupId>io.storj</groupId>
        <artifactId>storj_uplink</artifactId>
        <version>YOUR_UPLINK_VERSION</version> <!-- Check Storj docs for latest -->
    </dependency>
</dependencies>

For Gradle:

dependencies {
    implementation 'io.storj:storj_uplink:YOUR_UPLINK_VERSION' // Check Storj docs for latest
}

Replace YOUR_UPLINK_VERSION with the latest version number specified in the Storj Java SDK documentation.

Rust

Add uplink-rust to your Cargo.toml dependencies:

[dependencies]
uplink-rust = "YOUR_UPLINK_VERSION" # Check Storj docs for latest

Then run cargo build or cargo add uplink-rust to automatically add the latest version.

C# (.NET)

Install the NuGet package for the C# SDK:

dotnet add package Storj.SDK

Or via the NuGet Package Manager in Visual Studio.

Quickstart example

The following Go example demonstrates how to connect to Storj, upload a file, and download it. This requires an Access Grant string, which can be generated using the Storj Uplink CLI or from the Satellite web interface.

package main

import (
	"context"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strings"

	uplink "storj.io/uplink"
)

func main() {
	// Replace with your actual Storj Access Grant string
	accessGrantString := os.Getenv("STORJ_ACCESS_GRANT")
	if accessGrantString == "" {
		log.Fatal("STORJ_ACCESS_GRANT environment variable not set")
	}

	ctx := context.Background()

	// Parse the Access Grant
	access, err := uplink.ParseAccess(accessGrantString)
	if err != nil {
		log.Fatalf("Failed to parse access grant: %v", err)
	}

	// Open a project
	project, err := uplink.OpenProject(ctx, access)
	if err != nil {
		log.Fatalf("Failed to open project: %v", err)
	}
	defer project.Close()

	bucketName := "my-first-bucket"
	objectKey := "my-test-file.txt"
	content := "Hello, Storj decentralized cloud storage!"

	// Ensure the bucket exists
	_, err = project.EnsureBucket(ctx, bucketName)
	if err != nil {
		log.Fatalf("Failed to ensure bucket: %v", err)
	}
	fmt.Printf("Bucket '%s' ensured.\n", bucketName)

	// Upload the content
	upload, err := project.UploadObject(ctx, bucketName, objectKey, nil)
	if err != nil {
		log.Fatalf("Failed to initiate upload: %v", err)
	}

	_, err = io.Copy(upload, strings.NewReader(content))
	if err != nil {
		_ = upload.Abort()
		log.Fatalf("Failed to upload data: %v", err)
	}

	err = upload.Commit()
	if err != nil {
		log.Fatalf("Failed to commit upload: %v", err)
	}
	fmt.Printf("Object '%s' uploaded to bucket '%s'.\n", objectKey, bucketName)

	// Download the content
	download, err := project.DownloadObject(ctx, bucketName, objectKey, nil)
	if err != nil {
		log.Fatalf("Failed to initiate download: %v", err)
	}
	defer download.Close()

	downloadedContent, err := ioutil.ReadAll(download)
	if err != nil {
		log.Fatalf("Failed to read downloaded data: %v", err)
	}
	fmt.Printf("Downloaded content: %s\n", string(downloadedContent))

	// Verify content
	if string(downloadedContent) == content {
		fmt.Println("Content verification successful.")
	} else {
		fmt.Println("Content verification failed.")
	}
}

This example demonstrates the core workflow: parsing an access grant, opening a project, ensuring a bucket exists, uploading an object, and then downloading and verifying its content. Developers are encouraged to handle errors robustly and manage resources (like closing projects and downloads) appropriately.

For Node.js, Python, Java, Rust, and C# quickstart examples, refer to the official Storj documentation's quickstart guides for each specific language, as the patterns for object interaction remain similar across SDKs.

Community libraries

Beyond the official SDKs, the Storj ecosystem includes various community-contributed tools, wrappers, and integrations. These often extend functionality or provide compatibility with specific frameworks or platforms. While not officially maintained by Storj Labs, they can offer solutions for niche use cases or preferred development environments. Common types of community contributions include:

  • Framework Integrations: Libraries that facilitate Storj integration within popular web frameworks (e.g., Django, Ruby on Rails, Laravel) by offering storage backends or file system adapters.
  • Specialized Clients: Tools optimized for specific tasks, such as large file transfers with advanced progress reporting, or command-line utilities beyond the official Uplink CLI.
  • Language Bindings: Wrappers for libuplink in languages not officially supported, or alternative implementations that leverage different language paradigms.
  • Decentralized Application (dApp) Tools: Libraries that simplify embedding Storj into blockchain-based applications, often providing higher-level abstractions for common dApp storage patterns.

For example, some community efforts might involve integrating Storj with Firebase for file storage or creating plugins for content management systems. Developers interested in exploring community-contributed resources should consult the Storj GitHub organization and broader community forums, as these projects are often hosted and maintained independently. It is advisable to review the licensing, support, and maintenance status of community libraries before incorporating them into production systems, as their stability and longevity may vary compared to official SDKs.