Skip to main content

CLI Overview

The Mention CLI provides a command-line interface for interacting with the Mention API. It allows you to manage alerts, mentions, and application data directly from your terminal.

Installation

Install the Mention Python package:
pip install mention
Verify the installation:
mention --version

Authentication

The CLI requires an OAuth2 access token to authenticate with the Mention API. Set up authentication using environment variables:

Required Environment Variables

MENTION_ACCESS_TOKEN
string
required
Your Mention API OAuth2 access token

Optional Environment Variables

MENTION_ACCOUNT_ID
string
Default account ID for all commands (can be overridden with --account-id flag)
MENTION_BASE_URL
string
Custom API base URL (defaults to the official Mention API)
MENTION_TIMEOUT
number
Request timeout in seconds

Setting Up Environment Variables

Linux/macOS

Add to your ~/.bashrc, ~/.zshrc, or ~/.profile:
export MENTION_ACCESS_TOKEN="your_access_token_here"
export MENTION_ACCOUNT_ID="your_account_id_here"
Then reload your shell configuration:
source ~/.bashrc  # or ~/.zshrc

Windows (PowerShell)

$env:MENTION_ACCESS_TOKEN="your_access_token_here"
$env:MENTION_ACCOUNT_ID="your_account_id_here"
For persistent environment variables on Windows, use System Properties > Environment Variables.

Using a .env File

Create a .env file in your project directory:
MENTION_ACCESS_TOKEN=your_access_token_here
MENTION_ACCOUNT_ID=your_account_id_here
MENTION_BASE_URL=https://api.mention.com/api
MENTION_TIMEOUT=30
Load it before running commands:
source .env
mention app-data

Quick Start

Once configured, you can start using the CLI:
# Get application data (sources, languages)
mention app-data

# List all alerts
mention alerts list --account-id=abc123

# List mentions for an alert
mention mentions list --account-id=abc123 --alert-id=xyz789

Command Structure

The CLI uses a hierarchical command structure:
mention [global-options] <command> <subcommand> [options]

Global Options

--account-id
string
default:"$MENTION_ACCOUNT_ID"
Account ID (can also be set via MENTION_ACCOUNT_ID environment variable)Short form: -a
--output
string
default:"json"
Output format. Available options: json, tableShort form: -o
--version
boolean
Display the CLI version

Available Commands

The CLI provides the following command groups:

app-data

Get application data including available sources and languages.
mention app-data

alerts

Manage alerts for monitoring keywords and topics:
  • list - List all alerts for an account
  • get - Get details of a specific alert
  • create - Create a new alert
  • delete - Delete an alert

mentions

Manage mentions found by your alerts:
  • list - List mentions for an alert with filtering
  • get - Get a specific mention
  • curate - Update mention properties (favorite, read, trashed, tone)
  • mark-read - Mark all mentions as read for an alert
  • stream - Stream all mentions with automatic pagination

Output Format

By default, all commands output JSON formatted data:
mention alerts list --account-id=abc123
{
  "alerts": [
    {
      "id": "alert_123",
      "name": "My Brand",
      "query": {
        "type": "basic",
        "included_keywords": ["mycompany", "mybrand"]
      }
    }
  ]
}
Status messages are printed to stderr, so you can safely pipe JSON output:
mention alerts list --account-id=abc123 | jq '.alerts[0].name'

Error Handling

The CLI provides clear error messages:
$ mention alerts list
Configuration error: MENTION_ACCESS_TOKEN environment variable is required

Required environment variables:
  MENTION_ACCESS_TOKEN - Your Mention API access token

Optional environment variables:
  MENTION_ACCOUNT_ID  - Default account ID
  MENTION_BASE_URL    - API base URL

Exit Codes

  • 0 - Success
  • 1 - Error (configuration, API error, or general error)
  • 130 - Interrupted (Ctrl+C)

Next Steps

See the Command Reference for detailed documentation of all available commands and their options.

Build docs developers (and LLMs) love