Package Search Syntax

Cloudsmith provides a powerful and flexible query language that enables you to instantly find any package, in any repository, based on a comprehensive set of attributes. This syntax can be used in multiple areas of the product.

Our search syntax allows you to move beyond simple name-based searches and build highly specific queries using a wide range of criteria, including package format, version, size, upload date, dependencies, and even policy violation status. By combining these terms with boolean operators (AND, OR, NOT) and advanced matching logic, you can construct precise filters to isolate the exact artifacts you need, directly from the Web UI, API, or CLI.

Note

📘 The search syntax is fully "boolean", in that you can combine queries together with AND (i.e. find this AND that), or OR (i.e. find this OR that), or NOT (i.e. find NOT this). This is optional, if you don't put any boolean operators (AND/OR) in, we'll just assume that you want AND by default.

Search Terms

Search BySearch Terms Example
Name (name)name:my-package (package name contains "my-package"; use anchors for exact match)
Filename (filename)filename:my-package.ext (filename contains "my-package.ext"; use anchors for exact match)
Tag (tag)tag:latest (a package tag contains "latest"; use anchors for exact match)
Version - String-based (version)version:^1.1.0$ (package version is exactly 1.1.0)
version:1.1.0*post1 (package version contains 1.10 followed by post1).
Version - Semantic (version)version:1.1.0 (package version is "1.1.0")
version:>1.1.0 (package version is greater than "1.1.0")
version:<1.1.0 (package version is less than "1.1.0")
version:~=1.1.0 (package version is greater or equal to 1.1.0, but less than 1.2.0)
Prerelease (prerelease)true (packages are prerelease) false (packages are not prerelease)
Architecture (architecture)architecture:x86_64 (architecture is "x86_64")
Distribution (distribution)distribution:el/7 (distribution is "el", release is "7")
Format (format)format:deb (format is "deb" [debian])
Status (status)status:in_progress (status is "in_progress")
File Checksum (checksum)checksum:5afba (checksum contains "5afba")
Downloads (downloads)downloads:>8 (more than 8 downloads)
downloads:<1000 (at least 1, but less than 1000 downloads)
Package Type (type)type:binary (Binary Packages)
type:source (Source Packages)
type:combined (Binary and Source Packages)
Size in Bytes (size)size:>50000 (size is greater than 50000)
size:<10000 (size is less than 10000)
Uploaded Date (uploaded)uploaded:’1 day ago’ (uploaded more than one day ago) uploaded:’August 14, 2019 EST’ (uploaded on Aug 14th)
Entitlement Token Identifier (token)token:3lKPVJPosCsY (packages visible for specified token)
Dependencies (dependency)dependency:log4j (search for packages that have a dependency with "log4j" in the name).
dependency:log4j=1.2.17 (search for packages dependencies name including "log4j" & version matching 1.2.17).
dependency:log4j<2.0.0 (search for packages dependencies with name including "log4j" & version less than 2.0.0).
Repository (repository)repository:repo-name (Search for packages within the repository named "repo-name")
Debian: Componentdeb_component:component-name (Search for packages by Debian Component)
Docker: Image Digestdocker_image_digest:sha256:abcdef (Search for packages by Docker Image Digest)
Docker: Layer Digestdocker_layer_digest:sha256:abcdef (Search for packages by Docker Layer Digest)
Maven: GroupIDmaven_group_id:io.cloudsmith (Search for packages by Maven GroupID)
Packages that have violated a policy (policy_violated)true (packages that have violated a policy)
false (packages have not violated a policy)
Packages that have violated a vulnerability policy (vulnerability_policy_violated)true (packages that have violated a vulnerability policy)
false (packages have not violated a vulnerability policy)
Packages that have violated a license policy (license_policy_violated)true (packages that have violated a license policy)
false (packages have not violated a license policy)
Packages that have violated a deny list policy (deny_policy_violated)true (packages that have violated a deny list policy)
false (packages have not violated a deny list policy)

For all queries you can use:
~ for negation. (Example: ~foo)

For string queries you can use:
^ - to anchor to start of term. (Example: ^foo)
$ - to anchor to end of term. (Example: foo$)
* - for fuzzy matching. (Example: foo*bar)

For number or date queries you can use:
> - for values greater than. (Example: >foo)
>= - for values greater / equal. (Example: >=foo)
< - for values less than. (Example: <foo)
<= - for values less / equal. (Example: <=foo)

Please note, when you use a query like uploaded: >'1 month ago', that becomes uploaded > dd/mm/yy (i.e, within the last month).

For version queries you can use:
> - for versions greater than. (Example: >1.2.3.)
>= - for versions greater / equal. (Example: >=1.2.3)
< - for versions less than. (Example: <1.2.3)
<= - for versions less / equal. (Example: <=1.2.3)
~= - for versions greater than or equal to, upto the next incompatible version. (Example: ~=1.2.0)

Note

Remember: You can use any combination of AND, OR and NOT. You can use parentheses to group terms if required, as AND has a higher precedence than OR, and it may change the meaning of queries without it.

A Short Working Example

Suppose that you had the following packages:

  • AlphaLib, Version: 1.0
  • AlphaLib, Version: 1.1
  • AlphaLib, Version: 2.0
  • BetaLib: Version: 0.9

To find "AlphaLib" packages that are in the version 1.x series only, your query would be:
name:^AlphaLib$ AND version:~=1.0.

Which would provide the following results:

  • AlphaLib, Version: 1.0
  • AlphaLib, Version: 1.1

To bring the query down, we added the following parts:

  • name:^AlphaLib$ - Find a package name that is exactly "AlphaLib". Without the ^ (starts-with) and $ (ends-with), the query would be fuzzy, and potentially find packages called "AlphaLib2" or "FreeAlphaLib" too.
  • AND - We want to search for both the name and version together. Both must match for the results.
  • version:~=1.0 - Find package versions that are at-least 1.0, upto the next incompatible version (2.0).

Searching Packages via the Cloudsmith web app

At the top of every page is the search box:

Additional help and examples are available by hovering over the "? Search syntax" at the right side of the search box.

Searching Packages via the Cloudsmith API

Please see the Cloudsmith full API reference to learn how to:

  • List all of the packages in a Workspace (Organization).
  • List all of the packages in a Repository.

Then, you can use the query field in the URL request to search a package by any of the next fields:

  • name
  • filename
  • version
  • distribution
  • architecture
  • format
  • status

For example, to retrieve all packages named ms:

bash
curl -sL --request GET \
  --url "https://api.cloudsmith.io/v1/packages/<MY_WORKSPACE>/<MY_REPO>/?query=name:ms" \
  --header 'Authorization: Bearer <MY_API_TOKEN>'

Alternatively, you can use jq to search for a package in a repository by using any of the fields available in the json returned by the request. For example:

bash
curl -sL "https://api.cloudsmith.io/v1/packages/<MY_WORKSPACE>/<MY_REPO>/" \
  --header 'Authorization: Bearer <MY_API_TOKEN>' \
  | jq '.[] | select(.name == "requests")'

Searching Packages via the Cloudsmith CLI

To search packages using the Cloudsmith CLI, you use the cloudsmith list packages command in combination with the -q option:

shell
cloudsmith list packages OWNER/REPOSITORY -q "SEARCH_TERMS"

Example
To search for all debian packages:

shell
cloudsmith list packages cloudsmith/examples -q "format:deb"

Example
To search for the latest rpm and composer packages:

shell
cloudsmith list packages cloudsmith/examples -q "tag:latest AND (format:rpm OR format:composer)"

Example
To search for all python packages larger than 2KB with more than 50 downloads:

shell
cloudsmith list packages cloudsmith/examples -q "format:python AND downloads:>50 AND size:>2048"

Sorting Packages


Sorting Packages via the Cloudsmith web app

At the top of each repository packages page is the sorting dropdown:

The available sorting options are:

  • Name (A-Z)
  • Name (Z-A)
  • Uploaded At (Oldest FIrst)
  • Uploaded At (Newest First)
  • Size (Smallest First)
  • Size (Biggest First)
  • Total Downloads (Ascending)
  • Total Downloads (Descending)

Note that currently, the UI only supports sorting by one field at a time.

Sorting Packages via the Cloudsmith API

Please see the Cloudsmith full API reference to learn how to:

  • List all of the packages in a Workspace (Organization).
  • List all of the packages in a Repository.

Then, use the sort option to rank the result by any or many or the sort fields listed in the next section.

For example, to retrieve all of the packages of the workspace <MY_WORKSPACE> organized by ascending number of downloads:

bash
curl -sL --request GET \
  --url "https://api.cloudsmith.io/v1/packages/<MY_WORKSPACE>/?sort=downloads" \
  --header 'Authorization: Bearer <MY_API_TOKEN>'

Sorting search results is simple with Cloudsmith. A collection of one or more fields can be supplied in CSV (comma-separated value) format, and the results will be sorted based on the order of the fields provided.

Sort Fields

Sort BySort Field Example
Name (name)-name (sort by name alphabetically)
Format (format)-format (sort by format alphabetically e.g. alphine, maven, python)
Version - String-based (version)-version (sort by version, greatest first e.g. 1.2.1, 1.2.0, 1.1.0)
Status (status)
Size in Bytes (size)-size (sort by size in bytes, largest package first)
Downloads (downloads)downloads (sort by downloads ascending e.g. 0, 10, 50, 1,000)
Date (date)-date (sort by uploaded time, most recent first)

For all fields you can use:
- to sort by descending order. (Example: -date, -version)

A Short Worked Example

Suppose that you had the following packages:

NameFormatSizeVersionDownloads
cloudsmith-example-cliPython7221.2.0500
cloudsmith-example-cliPython7191.1.51000
cloudsmith-java-appMaven69101.0.02500
cloudsmith-example-pdfRaw3092.0.0100

To sort packages by size descending, your sort query would be:

-size

Which would provide the following results

  • cloudsmith-java-app, Size: 6910 bytes
  • cloudsmith-example-cli, Size: 722 bytes
  • cloudsmith-example-cli, Size: 719 bytes
  • cloudsmith-example-pdf, Size: 309 bytes

To sort packages by format alphabetically, with version descending, your sort query would be:

-format,-version

Which would provide the following results:

  • cloudsmith-java-app, Format: Maven, Version: 1.0.0
  • cloudsmith-example-cli, Format: Python, Version: 1.2.0
  • cloudsmith-example-cli, Format: Python, Version: 1.1.5
  • cloudsmith-example-pdf, Format: Raw, Version: 1.1.0

Sorting combined with Searching

Sorting can also be combined with querying. If you wanted to sort by most downloaded Python packages, your query and sort would be:

query=format:python&sort=-downloads

Which would provide the following results:

  • cloudsmith-example-cli, Format: Python, Version: 1.2.0, Downloads: 1000
  • cloudsmith-example-cli, Format: Python, Version: 1.2.0, Downloads: 500