Introduction to the Artifactory REST APIs

JFrog REST APIs

Products
JFrog Xray
Content Type
REST API
ft:sourceType
Paligo

Artifactory provides a convenient and up-to-date self-descriptive API that can be used by various tools/frameworks to automate the creation of REST calls.

Usage

Important

With the release of Artifactory 7.49.3, the REST APIs for all JFrog Platform functions - APIs that are not specific to Artifactory - have been moved to a dedicated section, Introduction to the JFrog Platform REST APIs

These include the following sections:

The Platform API page also contains the new SECURITY REST APIs (Users and Groups), which will eventually replace the Artifactory Security REST APIs.

Artifactory REST API endpoints can be invoked in any of the standard ways to invoke a RESTful API. This section describes how to use the Artifactory REST API using cURL as an example.

Using and Configuring cURL

/repo-key/path/to/artifact.ext

You can download cURL here. Learn how to use and configure cURL here.

Authentication

Artifactory's REST API supports these forms of authentication:

  • Basic authentication using your username and password

    Warning

    Basic authentication is not considered secure and is not recommended.

  • Using an access token instead of a password for basic authenticationAccess Tokens

  • Using an access token as a bearer token in an authorization header (Authorization: Bearer) with your access token

  • For MyJFrog authentication, see Generate a Token in MyJFrogGenerate a Token in MyJFrog

Artifactory version

To use your API key for Basic Authentication, it must be generated using Artifactory 4.4.3 or later. If generated on a previous version, you must regenerate your API key and use the new key as a password for basic authentication.

Note that from Artifactory 7.47.x, the API Key is being deprecated.

Using JFrog CLI

JFrog CLI is a compact and smart client that provides a simple interface to automate access to Artifactory. As a wrapper to the REST API, it offers a way to simplify automation scripts making them more readable and easier to maintain, features such as parallel uploads and downloads, checksum optimization, and wildcards/regular expressions make your scripts more efficient and reliable. Please note that several of the functions available through the REST API are also available through JFrog CLI and you should consider which method best meets your needs.

For more details on the download, installation, and usage of JFrog CLI, refer to the JFrog CLI.

Updating Artifactory System Configuration Files

Artifactory provides a flexible way to configure an existing Artifactory instance using a simple YAML configuration file. Run single or multiple configuration changes as needed, to create, update, and delete any elements in Artifactory. For more information, see Artifactory YAML Configuration.Artifactory YAML Configuration

Example - Deploying an Artifact

The example below demonstrates how to invoke the Deploy Artifact REST API.

  • You are using cURL from the unix command line, and are presently working from the home (~) directory of the user myUser

  • You wish to deploy the file myNewFile.txt, which is located in your Desktop directory, (~/Desktop/myNewFile.txt)

  • You have Artifactory running on your local system, on port 8081

  • You wish to deploy the artifact into the my-repository repository, under the my/new/artifact/directory/ folder structure, and wish to store the file there as file.txt.

  • You have configured a user in Artifactory named myUser, with password myP455w0rd!, and this user has permissions to deploy artifacts

  • Your API Key is ABcdEF

  • Where possible, the same example is demonstrated using JFrog CLI

To deploy the file using your username and password for authentication, you would use the following command:

Using cURL with the REST API

curl -u myUser:myP455w0rd! -X PUT "http://localhost:8081/artifactory/my-repository/my/new/artifact/directory/file.txt" -T Desktop/myNewFile.txt

Using JFrog CLI

jfrog rt u file.txt my-repository/my/new/artifact/directory/ --user=myUser --password=myP455w0rd!

To deploy the file using your API Key for basic authentication, you would use the following command:

Using cURL with the REST API

curl -u myUser:ABcdEF -X PUT "http://localhost:8081/artifactory/my-repository/my/new/artifact/directory/file.txt" -T Desktop/myNewFile.txt

Using JFrog CLI

jfrog rt u file.txt my-repository/my/new/artifact/directory/ --apiKey=ABcdEF

To deploy the file using your API Key in a header, you would use the following command:

Using cURL with the REST API

curl -H "X-JFrog-Art-Api:ABcdEF" -X PUT "http://localhost:8081/artifactory/my-repository/my/new/artifact/directory/file.txt" -T Desktop/myNewFile.txt

To deploy the file using your access token for basic authentication, you would use the following command:

Using cURL with an access token

curl -u myUser:<Token> -X PUT "http://localhost:8081/artifactory/my-repository/my/new/artifact/directory/file.txt" -T Desktop/myNewFile.txt

To deploy the file using your access token in a header, you would use the following command:

Using cURL with an access token

curl -H "Authorization: Bearer <Token>" -X PUT "http://localhost:8081/artifactory/my-repository/my/new/artifact/directory/file.txt" -T Desktop/myNewFile.txt

Base URL

The Platform REST URL is constructed of:

<JFrog URL>/<Service Context>/

For example:

# Using your JFrog URL 
http://myjfrog.acme.org/artifactory/

# Using your Artifactory server hostname and port
http://ARTIFACTORY_SERVER_HOSTNAME:8081/artifactory/

Working with Artifactory Cloud

JFrog Artifactory Cloud offers the same extensive functionality and capabilities for automation as an on-prem installation, including authentication, use of JFrog CLI and the REST API endpoints.

As a Cloud service, the URL is different from an on-prem installation and the REST API endpoints can be reached at:

https://<Server Name>.jfrog.io/artifactory/

Example

The snippets below apply the same Example - Deploying an Artifact described above to an Artifactory Cloud instance named "myArtifactoryCloud" (instead of to an on-prem installation).

To deploy the file using your username and password for authentication, you would use the following command:

Using cURL with the REST API for Artifactory Cloud

curl -u myUser:myP455w0rd! -X PUT "https://myartifactorycloud.jfrog.io/artifactory/my-repository/my/new/artifact/directory/file.txt" -T Desktop/myNewFile.txt

Using JFrog CLI

jfrog rt u file.txt my-repository/my/new/artifact/directory/ --user=myUser --password=myP455w0rd!

Note that using JFrog CLI is identical with an Artifactory Cloud instance. You only need to configure JFrog CLI with the correct URL for your instance.