Skip to main content

CLI for the Data Legion API — agent-friendly, fully async

Project description

datalegion-cli

The official command-line interface for the Data Legion API. Built for both humans and AI agents.

Look up people and companies by email, phone, name, domain, LinkedIn, or ticker symbol. Search across 1.5B+ contacts and 200M+ companies using SQL syntax. Clean, hash, and validate data fields before or after enrichment. Track credit usage and manage your configuration — all from the terminal.

pip install datalegion-cli
datalegion-cli config set api_key legion_your_key_here
datalegion-cli person enrich --email john@example.com

Features

  • Fully async — async from entry point to HTTP client, powered by asyncio and httpx
  • Agent-friendly — all output is JSON to stdout, logs go to stderr, supports --stdin for piping
  • Encrypted config — API keys are stored encrypted at rest (Fernet + PBKDF2, machine-tied)
  • Auto-update — checks GitHub releases and self-updates via Homebrew, GitHub release, git pull, or pip/uv
  • Multiple install methods — Homebrew, GitHub release, pip/uv (with private index support), or from source

Installation

Homebrew

brew install datalegion-ai/tap/datalegion-cli

From PyPI (or private index)

uv pip install datalegion-cli

Or with pip:

pip install datalegion-cli

To install from a private index:

uv pip install datalegion-cli --extra-index-url https://your-private-index.com/simple

From GitHub release

Download the .whl from the latest release and install:

uv pip install datalegion_cli-*.whl

From source

git clone https://github.com/datalegion-ai/datalegion-cli.git
cd datalegion-cli
uv sync

Configuration

Set your API key (stored encrypted on disk):

datalegion-cli config set api_key legion_your_key_here

Or via environment variable (takes precedence over file config):

export LEGION_API_KEY=legion_your_key_here

Other config options

# Set the API base URL
datalegion-cli config set api_base_url https://api.datalegion.ai

# Set install method for auto-update (brew, github, git, or pip)
datalegion-cli config set install_method brew

# View all config
datalegion-cli config list

# Show config file path
datalegion-cli config path

Config is stored at ~/.datalegion/config.toml. Override the location with LEGION_CONFIG_DIR.

Install method detection

The update command auto-detects how the CLI was installed:

Method Detection Update strategy
brew brew list finds the formula brew upgrade
github Set via config Downloads .whl from GitHub release
git .git directory in parent tree git pull --ff-only + uv sync
pip Default fallback uv pip install --upgrade

You can override detection by setting install_method in config. For pip installs from a private index, set the LEGION_PIP_INDEX_URL environment variable.

Usage

Person enrichment

# By email
datalegion-cli person enrich --email john@example.com

# By name + company
datalegion-cli person enrich --name "Jane Smith" --company "Acme Corp" --city "NYC"

# By LinkedIn
datalegion-cli person enrich --social-url "https://linkedin.com/in/johndoe"

# Multiple results with minimum confidence
datalegion-cli person enrich --email john@example.com --multiple --min-confidence high

# Select specific fields
datalegion-cli person enrich --email john@example.com --fields "full_name,emails,phones"

Person search

# SQL-based search
datalegion-cli person search "SELECT * FROM people WHERE company_name ILIKE '%google%' AND state = 'CA'" --limit 5

Company enrichment

# By domain
datalegion-cli company enrich --domain google.com

# By ticker symbol
datalegion-cli company enrich --ticker AAPL

# By name with industry context
datalegion-cli company enrich --name "Stripe" --industry "Financial Services"

Company search

# SQL-based search
datalegion-cli company search "SELECT * FROM companies WHERE industry ILIKE '%software%' AND legion_employee_count > 100"

Utility commands

# Clean and normalize fields
datalegion-cli utility clean '{"email": "John.Doe+tag@gmail.com", "phone": "(555) 123-4567"}'

# Hash an email for privacy-preserving lookups
datalegion-cli utility hash john@example.com

# Validate fields before enrichment
datalegion-cli utility validate --email "test@example.com" --phone "+15551234567"

Credits

# Check balance
datalegion-cli credits balance

# View usage history
datalegion-cli credits usage --from 2026-01-01 --to 2026-03-01

Other commands

# Check for updates
datalegion-cli update --check

# Self-update
datalegion-cli update

# Show version
datalegion-cli version

Agent / automation usage

The CLI is designed to be called by AI agents and scripts. Key patterns:

# All output is JSON to stdout — parse it directly
datalegion-cli person enrich --email john@example.com | jq '.matches[0].full_name'

# Pipe JSON payloads via stdin
echo '{"email":"john@example.com","company":"Acme"}' | datalegion-cli person enrich --stdin

# Suppress logs with --quiet (only JSON on stdout)
datalegion-cli --quiet person enrich --email john@example.com

# Errors are also JSON
datalegion-cli person enrich --email bad 2>/dev/null
# {"ok": false, "error": "bad_request", "message": "..."}

Global flags

Flag Description
--verbose / -v Enable debug logging to stderr
--quiet / -q Suppress all log output
--help Show help for any command

Development

# Install dev dependencies
uv sync

# Run tests
uv run pytest

# Lint
uv run ruff check src/ tests/

# Build wheel
uv build

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datalegion_cli-1.1.0.tar.gz (55.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datalegion_cli-1.1.0-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file datalegion_cli-1.1.0.tar.gz.

File metadata

  • Download URL: datalegion_cli-1.1.0.tar.gz
  • Upload date:
  • Size: 55.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for datalegion_cli-1.1.0.tar.gz
Algorithm Hash digest
SHA256 62f5fe29ed7eacbd9bed31e1577804e722571b848bea72c2cf91cc0f67e24f93
MD5 003d3d6d83af8b478d2a767763910363
BLAKE2b-256 190b91318172ba2c8b1fc3ad37278144c94ddcefd9db94a7fb4773a91ac39340

See more details on using hashes here.

File details

Details for the file datalegion_cli-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: datalegion_cli-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for datalegion_cli-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 539f583d0e90f370f2b41891b64d415c4650d6cce063e9623a9e37a8b607255f
MD5 7f092a37d673e8d8581ae120ee0f50a4
BLAKE2b-256 13014f2005737b85e1c2ccdfed3f753d56a1e3b91751d579aa979235be93bec7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page