Skip to main content

Overview

The CoinPaprika CLI supports both free tier (no authentication) and paid plans (API key required). You can configure your API key using three methods, each with a specific priority order.
The free tier provides 20,000 API calls per month without requiring an API key. For higher limits and premium features, upgrade to a paid plan at coinpaprika.com/api/pricing.

API Key Priority

When multiple authentication methods are configured, the CLI resolves your API key in the following priority order:
1

CLI Flag (--api-key)

Highest priority. Overrides all other methods.
coinpaprika-cli --api-key YOUR_KEY ticker btc-bitcoin
2

Environment Variable

Second priority. Set COINPAPRIKA_API_KEY in your shell.
export COINPAPRIKA_API_KEY="YOUR_KEY"
coinpaprika-cli ticker btc-bitcoin
3

Config File

Lowest priority. Stored in ~/.coinpaprika/config.json.
coinpaprika-cli config set-key YOUR_KEY
coinpaprika-cli ticker btc-bitcoin

Authentication Methods

How It Works

The CLI determines which authentication method to use based on the priority order defined in src/config.rs:80-106:
/// Resolve API key with priority: CLI flag > env var > config file
pub fn resolve_api_key(cli_key: Option<&str>) -> Option<String> {
    // 1. CLI flag
    if let Some(key) = cli_key {
        if !key.is_empty() {
            return Some(key.to_string());
        }
    }

    // 2. Environment variable
    if let Ok(key) = std::env::var("COINPAPRIKA_API_KEY") {
        if !key.is_empty() {
            return Some(key);
        }
    }

    // 3. Config file
    if let Ok(config) = load_config() {
        if let Some(key) = config.api_key {
            if !key.is_empty() {
                return Some(key);
            }
        }
    }

    None
}

API Endpoints

The CLI automatically selects the correct API endpoint based on whether you have an API key configured:
  • Free tier (no key): https://api.coinpaprika.com/v1
  • Paid plans (with key): https://api-pro.coinpaprika.com/v1
This is handled automatically in src/client.rs:11-16:
let coinpaprika_base = if api_key.is_some() {
    "https://api-pro.coinpaprika.com/v1".to_string()
} else {
    "https://api.coinpaprika.com/v1".to_string()
};

Security Best Practices

Never commit API keys to version control or share them publicly. Treat your API key like a password.

Config File Security

On Unix systems, the CLI automatically sets secure permissions:
  • Config directory: 0700 (owner read/write/execute only)
  • Config file: 0600 (owner read/write only)

Checking Your Key Source

Verify where your API key is being loaded from:
coinpaprika-cli config show
Possible sources:
  • CLI flag (--api-key)
  • Environment variable (COINPAPRIKA_API_KEY)
  • Config file (~/.coinpaprika/config.json)
  • Not set (using free tier)

Troubleshooting

Invalid API Key Error

If you see this error:
Invalid API key. Check your key with `coinpaprika-cli config show`
Solution:
  1. Verify your key is correct: coinpaprika-cli config show
  2. Regenerate your key at coinpaprika.com/api
  3. Update your configuration: coinpaprika-cli config set-key NEW_KEY

Plan Tier Errors

If you see “This endpoint requires a higher-tier plan”:
# Check your current plan
coinpaprika-cli key-info

# View available plans
coinpaprika-cli plans
Upgrade at coinpaprika.com/api/pricing
  • coinpaprika-cli config show - View current configuration
  • coinpaprika-cli config set-key <KEY> - Set API key
  • coinpaprika-cli config reset - Delete configuration
  • coinpaprika-cli key-info - Check API key details (paid plans only)
  • coinpaprika-cli plans - View free tier limits and paid plans
  • coinpaprika-cli onboard - Interactive setup wizard

Build docs developers (and LLMs) love