Download Using APIs

 

Bintray exposes APIs with which users can automatically download package files, specified by their URLs, using different tools. These tools depend on the repository type, package type, and other criteria, and may be build tools (such as Maven and Gradle), package management tools (such as Debian and RPM) and others (such as the HTTP client cURL). To download a file using APIs you need to specify the precise URL that corresponds to the file’s location within Bintray.

Files are stored in Bintray in a well-defined structure according to the repository and package in which they reside as well as in an additional Target Repository Path that the file’s owner can specify while performing the upload. 


A file’s URL is constructed as follows:

http://dl.bintray.com/<USER_NAME>:<API_KEY>/<SUBJECT_NAME>/<REPO_NAME>/<FILE_PATH>

where:

  • SUBJECT_NAME is the Bintray user or organization that owns the repository.

  • USER_NAME is your Bintray user name and API_KEY is your Bintray API Key
    (USER_NAME and API_KEY are optional parameters and are only needed when you are doing an authenticated download.)

  • REPO_NAME is the name of the repository in which the file is stored

  • FILE_PATH is the full path to the file you want to download. 

For example, to use cURL to download a file called: “myfile.bin” ,
that was uploaded using a Target Repository Path of “com/acme/projectx/rel15”,
to a repository called “myrepo”,
by a user whose username is “john”,
you would use the following line of code:

curl -u <YOUR USER_NAME>:<YOUR API_KEY> https://dl.bintray.com/acme/releases/rel15/module-x/installer.bin -o /tmp/installer.bin

As a convenience, each repository and package offers a Set Me Up! button, which displays a window showing download instructions for each tool that is relevant to the specific repository or package.

The example below shows a Set Me Up! window for a Maven repository. It includes instructions for download using the Maven client as well as general instructions in a line of cURL script that other tools can use:
Set Me Up! for a repo (downloading)

Clicking the different options in this window displays instructions for the relevant procedure, with GUI screenshots or lines of code where necessary.


Authenticated Downloads
There are two cases in which you must include authentication credentials, your Bintray Username and your API Key.

  • The package is stored in a private repository.
    (Exception: If you are downloading the package using a Signed URL, just use the URL provided to you without adding authentication details – that’s the purpose of Signed URLs)

  • You are downloading an unpublished package from your own repository.

For more details on how to download files using REST, please refer to Download Content in the Bintray REST API documentation.