12/04/2026 12:00:00 PM por Fábio Chicout

The Terminal-First Researcher (Part 3): Environment Setup & Secure Configuration with zotero-cli

The Terminal-First Researcher (Part 3): Environment Setup & Secure Configuration with zotero-cli

Track 2: Personal Library & Solo Scientist
In Part 2, we established the mental model of Zotero's cloud and local architecture. In Part 3, we get hands-on: provisioning API credentials, configuring the interactive wizard (zotero-cli init), securing sensitive tokens, and unlocking automated research accelerators with Unpaywall and Semantic Scholar.

Connecting a command-line tool to your academic library requires proper authentication and permission scoping. A common pitfall is generating an API key with excessive privileges or storing plaintext credentials insecurely.

In this guide, we walk through the exact steps to configure zotero-cli cleanly, safely, and reproducibly across Linux, macOS, and Windows environments.


1. Provisioning Your Zotero Credentials

To allow zotero-cli to speak to your library, you need two pieces of information from the official Zotero portal:

  1. Personal User ID: Navigate to zotero.org/settings/security. Under the Applications header, find the line: "Your userID for API calls is XXXXXXX". This numeric identifier uniquely pins your personal library.
  2. API Key: On the same page, click Create new private key. Give it a descriptive name (e.g., terminal-workstation), enable Allow library access and Allow write access, and click Save Key. Copy the key immediately; Zotero will not display it again.

2. Interactive Setup via zotero-cli init

The easiest way to initialize your environment is using the built-in wizard:

$ zotero-cli init

The wizard asks for your API key, shows which account it belongs to, then asks for the library type and ID plus a few optional settings. It verifies the credentials with a read request over HTTPS and writes your configuration file:

$ zotero-cli init
─────────────── Zotero CLI Configuration Wizard ───────────────
Please find your API Key and Library ID at https://www.zotero.org/settings/keys

Enter your Zotero API Key:
✔ Key belongs to 'your-username' (User ID: 1234567)

Library Type [user/group] (user):
Library ID (your User ID) (1234567):

Advanced Services (Optional)
Semantic Scholar API Key ():
Unpaywall Email (): me@university.edu
Path to zotero.sqlite, for --offline (optional) ():

Verifying credentials...
✔ Credentials verified successfully!

✔ Configuration saved to:
/home/you/.config/zotero-cli/config.toml

3. Configuration Layout & File Locations

zotero-cli respects OS-native standard directories:

  • Linux / macOS: ~/.config/zotero-cli/config.toml
  • Windows: %APPDATA%\zotero-cli\config.toml

Inspecting the generated config.toml:

# Zotero CLI Configuration
[zotero]
api_key = "your_api_key"
library_id = "1234567"
library_type = "user"
unpaywall_email = "me@university.edu"

Optional answers left empty are not written. To use --offline later, give the path to zotero.sqlite when the wizard asks, or add database_path to the [zotero] table.

4. CI/CD & Headless Server Deployment: Environment Overrides

When running zotero-cli inside Docker containers, automated GitHub Actions, or Forgejo CI runners, you should avoid committing config.toml to source control. zotero-cli natively respects standard environment variables:

export ZOTERO_API_KEY="your_api_key"
export ZOTERO_USER_ID="1234567"
export ZOTERO_LIBRARY_TYPE="user"
export UNPAYWALL_EMAIL="me@university.edu"

5. Verifying Installation Health

To check your configuration and the connections to external services, run the built-in diagnostic commands (system check does not test the local SQLite file):

# Inspect current configuration and active library context
$ zotero-cli system info

# Run automated connectivity checks across all configured APIs
$ zotero-cli system check

Output of system check without the optional API keys:

                                 Zotero CLI Diagnostics
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Service          ┃ Status         ┃ Details                                           ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Zotero API       │ CONNECTED      │ Credentials verified                              │
│ Semantic Scholar │ NOT CONFIGURED │ No API key set (works anonymously, rate-limited)  │
│ Unpaywall        │ CONNECTED      │ Reachable                                         │
│ PubMed/NCBI      │ NOT CONFIGURED │ No NCBI key set (works anonymously, rate-limited) │
└──────────────────┴────────────────┴───────────────────────────────────────────────────┘
Up Next in Part 4
With our authentication established and our diagnostic health verified, we are ready to populate our library. In Part 4, we examine Rapid Ingestion: adding papers in seconds via DOI, pulling literature in bulk from arXiv, and importing existing BibTeX libraries directly into target collections.