> For the complete documentation index, see [llms.txt](https://datasherlock.gitbook.io/datasherlock/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://datasherlock.gitbook.io/datasherlock/clients/cli.md).

# CLI

### Installation <a href="#installation" id="installation"></a>

The most convenient way to interact with our API is by using our cross-platform CLI:

```bash
curl -sL https://raw.githubusercontent.com/datasherlocks/sherlock/main/install.sh |  sudo bash -s -- -b /usr/local/bin
```

Alternatively, if you prefer using Homebrew:

```bash
brew install datasherlocks/homebrew-tap/sherlock
```

### API Token Setup <a href="#api-token-setup" id="api-token-setup"></a>

Before using the Datasherlocks CLI, you need to set up your API token. Visit the Organization [settings page](https://datasherlocks.io/settings/organization/tokens) to create an API token for your client. Once you have created the token, set it as a new environment variable:

```bash
export DS_API_TOKEN=*******
```

You are now ready to use the Datasherlocks CLI to manage your agents and interact with the Datasherlocks platform.

### Commands <a href="#commands" id="commands"></a>

The Datasherlocks CLI provides several commands to manage and query agents, as well as perform other tasks. Here are the available commands:

#### register <a href="#register" id="register"></a>

Use the register command to register a Datasherlocks agent with the platform. This command requires a configuration file and agent name.

Example:

```bash
sherlock register --config /path/to/config.yaml --name <AGENT_NAME>
```

#### ask <a href="#ask" id="ask"></a>

With the ask command, you can send a question to a Datasherlocks agent running on a specific host. You need to specify the question, agent ID, and optionally, the output format (JSON or table).

Example:

```bash
sherlock ask --question "How many users are active?" --id 123 --output table
```

#### list <a href="#list" id="list"></a>

The list command retrieves a list of Datasherlocks agents registered with the platform. It provides details such as agent ID, name, host, database, username, type, and remote URL.

Example:

```bash
sherlock list
```

#### serve <a href="#serve" id="serve"></a>

The serve command starts the Datasherlocks agent using the provided configuration file. It initializes the agent and allows it to communicate with the Datasherlocks platform. Please note that the serve command is intended for local testing only and is not recommended for production use.

Example (Local Testing):

```bash
sherlock serve -l --config /path/to/config.yaml
```

Example (Production Deployement)

```bash
sherlock serve --config /path/to/config.yaml
```

NOTE: For production deployments, we recommend following our AWS/Kubernetes deployment guide, which provides instructions for deploying the agent in a production environment.
