October 07, 2015

Getting Started with the Algorithmia Command Line Interface (CLI)

[stag_button url="https://algorithmia.com/developers/clients/cli/" style="red" size="large" type="stroke" target="_blank" icon="exclamation" icon_order="before"]These instructions are out-of-date. Please See https://algorithmia.com/developers/clients/cli/ instead.[/stag_button]


Algorithmia has released a command line interface (CLI)! This new, cross-platform tool allows you to use the command line to call more than 1,600 algorithms from the Algorithmia API.

The official docs can be found in the README on GitHub, but we’ll do a quick walkthrough to get you up and running.


Setting up the Algorithmia CLI is easy.


Download and extract the OSX tarball with this cURL command:

[code curl]
$ curl -L https://github.com/algorithmiaio/algorithmia-cli/releases/download/v1.0.0-beta.2/algorithmia_osx.tar.gz | tar -xz

We recommend putting it within your PATH with the following:

[code curl]
$ sudo mv algo /usr/local/bin/

Windows (64-bit)

First, install OpenSSL for Windows.

Next, download and extract the Windows zip file. We recommend putting it within your PATH.

Looking for instructions for Debian/Ubuntu or Arch installs? Find them on the official README.

Configure the CLI:

Before we can start making calls to the APIs, first we need configure our authentication. Run the command:
[code curl]
$ algo auth
You’ll be prompted to input your API key for a default profile. If you’d like to create more than one profile, simply run algo auth [<profile>] for the same interactive prompt. For more information, see the auth command help with algo auth --help.

Check that your profile is configured by running algo ls.


Now that we’re set up, let’s try executing some algorithms! We’re going to start with something simple, the Factor algorithm that takes in integer and returns its prime factors. You can find the details about this algorithm on the description page.
[code curl]
$ algo run kenny/factor -d 19635
Here we see the basic syntax: algo run, followed by the algorithm’s username and algorithm name (kenny/factor), the data options, and finally the input. The response we got back was just the result of the algorithm, but we can also add the option --response-body to see the full JSON response:
[code curl]
$ algo run kenny/factor -d 19635 --response-body
Run algo run --help to see more command options, including the data input and output options.

The Algorithmia CLI is also great for interacting with the Algorithmia API. You can use the CLI to create and manage your data directories. Let’s say you want to create a new data directory and upload some files-it’s easy with the CLI.

First, create a new data directory:
[code curl]
$ algo mkdir .my/favoritepics

Created directory data://.my/favoritepics

Copy a file from your local directory to the new data directory:
[code curl]$ algo cp puppies.png data://.my/favoritepics

Uploaded data://.my/favoritepics/puppies.png

When you’ve finished uploading, check that everything you expect is in your data directory:
[code curl]
$ algo ls .my/favoritepics

puppies.png kittens.jpg baby_turtles.jpg


Algorithmia CLI use of opencv/SmartThumbnail


Run algo --help for additional usage information and to learn about other command options. Be sure to check out the official README for even more detailed instructions on using the Algorithmia CLI and new release updates!

Matt Kiser

Matt Kiser

More Posts

Here's 50,000 credits
on us.

Algorithmia AI Cloud is built to scale. You write the code and compose the workflow. We take care of the rest.

Sign Up