Package Download


There are three basic ways to download a package from a Cloudsmith repository:

  • Via a native package manager
  • Via the Cloudsmith web app
  • Via the Cloudsmith CLI

You cannot download a package directly using the Cloudsmith API. However, you can use the API to obtain a URL (cdn_url) that you can then use to download a package.


Download via Native Package Manager

Each repository contains context-aware documentation for setting up and downloading packages using the native package managers (such as apt, npm or gem for example). Click the "Push/Pull Packages" button:

This will bring you to a window with a list of all supported package manager formats:

For example, If you select "Ruby" from the window, you are then presented with the guide on how to Pull or Push a ruby package in this repository. Go to the Pull Package tab to learn how to download a ruby package from this repository:

The instructions for downloading and installing a package using a native package manager are available by pressing the "Use Package" button on any package detail page:

There you are presented with contextual instructions for how to use a package:

Download via Cloudsmith web app

You can download a package directly from the Cloudsmith Website.

Public Repositories

You can download any package from the packages list by clicking the expose more button on the right of the page, or by clicking the green "Download" button on a package detail page:

Private Repositories

Downloading packages from a private repository is a little different. Click the download button.

You will be prompted to enter an Entitlement token:

See Entitlements and Sharing a Private Package for more details on Entitlement Tokens.

Download via Cloudsmith CLI

You can download a package by using the cloudsmith download command:

bash
cloudsmith download my-workspace/my-repo package-name

Useful flags

FlagDescription
--dry-runPreview which files will be downloaded by a command.
--outfileDefine a custom output directory for the download.
--all-filesDownload all associated package assets. For example, sources, javadoc, and SBOMs.
--download-allDownload all matching packages where multiple packages share the same name or version.
--versionSpecify a package version to download.
--tagFilter by package tag. For example, latest, stable, or beta.
--formatFilter by package format.
--archFilter by package architecture.
--osFilter by package operating system (OS).
--filenameFilter by filename. You can filter by exact filename, or by glob pattern.

Examples

Download the latest version of a package:

bash
cloudsmith download my-workspace/my-repo mypackage

Download to a specific directory:

bash
cloudsmith download my-workspace/my-repo mypackage --outfile /tmp/myfiles/

Download all associated package assets:

bash
cloudsmith download my-workspace/my-repo mynugetpackage --all-files

Filter by package tag:

bash
cloudsmith download my-workspace/my-repo package-name --tag latest

Filter by format and architecture:

bash
cloudsmith download my-workspace/my-repo package-name --format deb --arch amd64

Filter by filename (exact or glob pattern):

bash
cloudsmith download my-workspace/my-repo package-name --filename '*.nupkg'
cloudsmith download my-workspace/my-repo package-name --filename 'mypackage-1.0.0.nupkg'

Download all matching packages where multiple packages share the same name/version:

bash
cloudsmith download my-workspace/my-repo package-name --download-all

Combine --download-all with --filename to download a subset of packages:

bash
cloudsmith download my-workspace/my-repo package-name --download-all --filename '*.snupkg'

For all available command options, see the cloudsmith download --help output.

Bulk Package Download

You cannot bulk download packages using the Cloudsmith web app, but you can do it with a little scripting using the Cloudsmith CLI. The Cloudsmith CLI ships as a standalone binary for Linux, macOS, and Windows, so no Python runtime is required. See Command-Line Interface for installation options.

The basic premise of these examples is that you use the Cloudsmith CLI to list the contents of the repository, extract the download URL for each package, and then download each package.

Linux Example (bash)

Please ensure that you have first set up the Cloudsmith CLI with your API key (or pass it to the cloudsmith command using the -k flag). See the CLI documentation for full details: Command-Line Interface

shell
account="your-account"
repository="your-repo"

urls=$(cloudsmith ls pkgs $account/$repository -F json | jq -r '.data[].cdn_url')
for url in $urls; do
  wget $url
done
shell
account="your-account"
repository="your-repo"
token="your-entitlement-token"

urls=$(cloudsmith ls pkgs $account/$repository -F json | jq -r '.data[].cdn_url')
for url in $urls; do
  wget  --http-user=$account --http-password=$token $url
done

These examples also use jq for filtering and processing the JSON returned by Cloudsmith CLI list packages (cloudsmith ls) command.

While using the cdn_url returned from the Cloudsmith CLI or API will work for downloading most packages, if you need to also download docker manifest files you can utilize a url in the following format to grab them : https://docker.cloudsmith.io/v2/<workspace>/<repository>/<package name>/manifests/<tag>

You can also add search queries to the command to limit what is downloaded, e.g:

To download files of version 1.0 only:
urls=$(cloudsmith ls pkgs $account/$repository -F json -q 'version:1.0' | jq -r '.data[].cdn_url')

To download npm packages only:
urls=$(cloudsmith ls pkgs $account/$repository -F json -q 'format:npm' | jq -r '.data[].cdn_url')

Windows example (Windows PowerShell 5.1 or PowerShell 7+)

Please ensure that you have added the Cloudsmith CLI directory to your PATH (the install script reports it as bin_dir) and also that you've got your API key from https://app.cloudsmith.com/settings/api-keys if the repository is private.

powershell
$account = "your-account"
$repository = "your-repository"
$key = "your-API-key"

$json = $(cloudsmith.exe ls pkgs $account/$repository -F json -k $key)
$urls = $json | ConvertFrom-Json | ForEach-Object { $_.data.cdn_url }

$wc = New-Object System.Net.WebClient
$creds = new-object System.Net.NetworkCredential("token", $key)

Foreach ($url in $urls) {
  echo "Downloading $url ..."
  $filename = [System.IO.Path]::GetFileName($url)
  $cred_cache = new-object System.Net.CredentialCache
  $cred_cache.Add($url, "Basic", $creds)
  $wc.Credentials = $cred_cache
  $wc.DownloadFile($url, $filename)
}