<commit_before>---
layout: article
title:  "CLI"
excerpt: "Get familiar with the CLI client."
categories: clients
tags: [clients]
show_related: true
image:
    teaser: /language_logos/cli.svg
redirect_from:
  - /application-development/client-guides/cli/
  - /application-development/guides/cli/
---

The Algorithmia CLI is a cross-platform tool for interfacing with algorithms and the Algorithmia Data API.

This guide will cover:

* [Installation](#installing-the-algorithmia-cli)
* [Authentication](#configure-authentication)
* [Usage](#usage)
* [Command Options](#options)
* [The Data API](#the-algorithmia-data-api)
* [Using Multiple Profiles](#using-multiple-profiles)

Check out the tool in use in this short demo video (click to watch on YouTube):
[![Example CLI Usage](https://j.gifs.com/v1egak.gif)](https://www.youtube.com/watch?v=mAJagjRl_qk)

## Installing the Algorithmia CLI

The latest releases & changelog can be found [here](https://github.com/algorithmiaio/algorithmia-cli/releases/latest).

**Linux and OSX**

Install is by running:

{% highlight bash %}
curl -sSLf https://algorithmia.com/install.sh | sh
{% endhighlight %}

On some linux variants, you may need to preinstall curl, file, and git via a command such as:

{% highlight bash %}
apt install curl file git
{% endhighlight %}

**Windows**

Download and extract the [latest Windows x86_64 zip file](https://github.com/algorithmiaio/algorithmia-cli/releases/download/v1.0.1/algorithmia-v1.0.1-x86_64-pc-windows-msvc.zip). We recommend putting it within your `PATH`.

If needed, you can also find both MSVC and GNU builds for x86 and x86_64 on the [release page](https://github.com/algorithmiaio/algorithmia-cli/releases/latest).


**Installation note: Python environment variable**

If you'll be running Python algos, also set the version via `export LANGUAGE_VERSION=python2` or `export LANGUAGE_VERSION=python3`

## Configure Authentication

In order to make calls with the CLI, you'll need to configure the authentication with an API key. If you don't already have an API key, get started by signing up for an account at [Algorithmia.com](/). Once you've completed the sign up process, copy the API key from your account dashboard.

Begin the configuration process by running the command `algo auth`.
You will see an interactive prompt to guide you through setting up a default profile:

{% highlight text %}
$ algo auth
Configuring authentication for 'default' profile
Enter API Endpoint [https://api.algorithmia.com]: (press Enter)
Enter API Key (prefixed with 'sim'):
Profile is ready to use. Test with 'algo ls'
{% endhighlight %}

See [Using multiple profiles](#using-multiple-profiles) for instructions on how to set authenticate and use more than one profile with the Algorithmia CLI tool.

{% if site.enterprise %}
#### Enterprise Users Only: Specifying an On-Premises or Private Cloud Endpoint
If you are running [Algorithmia Enterprise](/enterprise), replace the default API Endpoint (`https://api.algorithmia.com`) with your own API endpoint URL.
{% endif %}

## Usage

To call an algorithm from the CLI, use the command syntax: `algo run`, followed by the algorithm’s username and algorithm name, the data options, and finally the input. Here is a basic example calling the [Factor algorithm](https://algorithmia.com/algorithms/kenny/Factor):

{% highlight text %}
$ algo run kenny/factor -d 19635
[3,5,7,11,17]
{% endhighlight %}

Add the option `--response-body` to see the full JSON response:

{% highlight text %}
$ algo run kenny/factor -d 19635 --response-body
{ "result": [3,5,7,11,17],
  "metadata": { "content_type":"json", "duration":0.001427314} }
{% endhighlight %}

Run `algo run --help` to see more command options or view the following [Options](#options) section.

### Options

#### Input Data Options
There are several options for specifying the type and source of input data. The Algorithmia CLI supports JSON, text, and binary data, as well as an option to auto-detect the data type.

| Option Flag               | Description |
| :------------             | :--------------- |
| -d, \--data <data>         | If the data parses as JSON, assume JSON, else if the data is valid UTF-8, assume text, else assume binary |
| -D, \--data-file <file>    | Same as --data, but the input data is read from a file |
<commit_msg>added information about enterprise cli endpoint needing the api prefix<commit_after>---
layout: article
title:  "CLI"
excerpt: "Get familiar with the CLI client."
categories: clients
tags: [clients]
show_related: true
image:
    teaser: /language_logos/cli.svg
redirect_from:
  - /application-development/client-guides/cli/
  - /application-development/guides/cli/
---

The Algorithmia CLI is a cross-platform tool for interfacing with algorithms and the Algorithmia Data API.

This guide will cover:

* [Installation](#installing-the-algorithmia-cli)
* [Authentication](#configure-authentication)
* [Usage](#usage)
* [Command Options](#options)
* [The Data API](#the-algorithmia-data-api)
* [Using Multiple Profiles](#using-multiple-profiles)

Check out the tool in use in this short demo video (click to watch on YouTube):
[![Example CLI Usage](https://j.gifs.com/v1egak.gif)](https://www.youtube.com/watch?v=mAJagjRl_qk)

## Installing the Algorithmia CLI

The latest releases & changelog can be found [here](https://github.com/algorithmiaio/algorithmia-cli/releases/latest).

**Linux and OSX**

Install is by running:

{% highlight bash %}
curl -sSLf https://algorithmia.com/install.sh | sh
{% endhighlight %}

On some linux variants, you may need to preinstall curl, file, and git via a command such as:

{% highlight bash %}
apt install curl file git
{% endhighlight %}

**Windows**

Download and extract the [latest Windows x86_64 zip file](https://github.com/algorithmiaio/algorithmia-cli/releases/download/v1.0.1/algorithmia-v1.0.1-x86_64-pc-windows-msvc.zip). We recommend putting it within your `PATH`.

If needed, you can also find both MSVC and GNU builds for x86 and x86_64 on the [release page](https://github.com/algorithmiaio/algorithmia-cli/releases/latest).


**Installation note: Python environment variable**

If you'll be running Python algos, also set the version via `export LANGUAGE_VERSION=python2` or `export LANGUAGE_VERSION=python3`

## Configure Authentication

In order to make calls with the CLI, you'll need to configure the authentication with an API key. If you don't already have an API key, get started by signing up for an account at [Algorithmia.com](/). Once you've completed the sign up process, copy the API key from your account dashboard.

Begin the configuration process by running the command `algo auth`.
You will see an interactive prompt to guide you through setting up a default profile:

{% highlight text %}
$ algo auth
Configuring authentication for 'default' profile
Enter API Endpoint [https://api.algorithmia.com]: (press Enter)
Enter API Key (prefixed with 'sim'):
Profile is ready to use. Test with 'algo ls'
{% endhighlight %}

See [Using multiple profiles](#using-multiple-profiles) for instructions on how to set authenticate and use more than one profile with the Algorithmia CLI tool.

{% if site.enterprise %}
#### Enterprise Users Only: Specifying an On-Premises or Private Cloud Endpoint
If you are running [Algorithmia Enterprise](/enterprise), replace the default API Endpoint (`https://api.algorithmia.com`) with your own API endpoint URL. Note that it must contain the `api` prefix, so if your domain is ` https://algorithmia.companyname.com ` then your API Endpoint should be `https://api.algorithmia.<EMAIL>`
{% endif %}

## Usage

To call an algorithm from the CLI, use the command syntax: `algo run`, followed by the algorithm’s username and algorithm name, the data options, and finally the input. Here is a basic example calling the [Factor algorithm](https://algorithmia.com/algorithms/kenny/Factor):

{% highlight text %}
$ algo run kenny/factor -d 19635
[3,5,7,11,17]
{% endhighlight %}

Add the option `--response-body` to see the full JSON response:

{% highlight text %}
$ algo run kenny/factor -d 19635 --response-body
{ "result": [3,5,7,11,17],
  "metadata": { "content_type":"json", "duration":0.001427314} }
{% endhighlight %}

Run `algo run --help` to see more command options or view the following [Options](#options) section.

### Options

#### Input Data Options
There are several options for specifying the type and source of input data. The Algorithmia CLI supports JSON, text, and binary data, as well as an option to auto-detect the data type.

| Option Flag               | Description |
| :------------             | :--------------- |
| -d, \--data <data>         | If the data parses as JSON, assume JSON, else if the data is valid UTF-8, assume text, else assume binary |
| -D, \--data-file <file>    | Same as --data, but the input data is read from a file |

{'fraction_non_alphanumeric': 0.11238609517381033, 'fraction_numerical': 0.013049836877039037, 'mean_word_length': 4.257244234180958, 'pattern_counts': {'":': 8, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 20, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1509679', 'n_tokens_mistral': 2709, 'n_tokens_neox': 2523, 'n_words': 1046}