Skip to main content

Python CLI for interacting with the January Mirror API.

Project description

Mirror CLI

Python CLI to interact with the January Mirror API. An API key is required.

Install

python3 -m venv .venv
source .venv/bin/activate
pip install .

Python 3.10+ is required. The only runtime dependency is requests.

Configure

  • MIRROR_API_KEY — your API key. You get this from the January team.
  • MIRROR_BASE_URL — (optional) the base URL for the Mirror API.

Usage

Run via mirror-cli ... or python -m mirror_cli ... from this folder.

Active patient state

Most commands need a --patient-id. To save typing, the CLI caches the last created patient as the "active patient" in your local config (~/.config/mirror-cli/context.json). If you omit --patient-id, commands will use this active patient. You can set or change it explicitly with mirror-cli use-patient --patient-id ..., view it with mirror-cli active-patient, or clear it with mirror-cli clear-active-patient. Passing --patient-id always overrides the active value.

mirror-cli create-patient --first-name Jane --last-name Doe --gender female --birthdate 1990-01-01
mirror-cli list-patients --limit 20
mirror-cli upload-document --file ./sample_data/sample_labcorp.pdf
mirror-cli list-documents
mirror-cli get-report --include-content --poll-interval 5 --max-wait 3600

mirror-cli use-patient --patient-id pat_123        # set active patient
mirror-cli active-patient                           # show active patient
mirror-cli clear-active-patient                     # clear active patient

Global flags: --base-url, --api-key, --timeout, --json, --verbose.

Notes

  • Document upload uses the two-step intent + presigned POST flow from the provided Postman collection.
  • Report retrieval starts the job and polls until completion (or until --max-wait elapses).

Typical flow

  1. Create a patient:
mirror-cli create-patient --first-name Jane --last-name Doe --gender female --birthdate 1990-01-01
  1. Upload a document (intent + presigned upload happen automatically):
mirror-cli upload-document --patient-id pat_123 --file ./lab.pdf
  1. Verify the upload:
mirror-cli list-documents --patient-id pat_123
  1. Request a report (starts the job and polls until done):
mirror-cli get-report --patient-id pat_123 --include-content --poll-interval 5 --max-wait 180

When completed, the CLI prints Report URL: <presigned link>; use --json to see the full payload. Flags --job-id, --force-context, and --force-report are available when you need more control.

Active patient helper:

  • After create-patient, the returned ID is saved as the active patient.
  • Commands that take --patient-id will default to the active patient if you omit the flag; you can always override by passing --patient-id explicitly.
  • Manage it explicitly with mirror-cli use-patient --patient-id ..., mirror-cli active-patient, and mirror-cli clear-active-patient.

Publish (manual)

  1. Bump the version in pyproject.toml.
  2. Build from the mirror-cli/ folder:
    python -m pip install --upgrade build twine
    python -m build
    
  3. Upload with Twine (PyPI):
    export PYPI_TOKEN="pypi-********"
    python -m twine upload dist/* -u __token__ -p "$PYPI_TOKEN"
    
    For TestPyPI, add --repository testpypi. Note: Token is saved in 1Password with the main account credentials.
  4. Verify:
    pip install --upgrade mirror-cli
    mirror-cli --version
    

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

mirror_cli-0.1.2.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

mirror_cli-0.1.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file mirror_cli-0.1.2.tar.gz.

File metadata

  • Download URL: mirror_cli-0.1.2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for mirror_cli-0.1.2.tar.gz
Algorithm Hash digest
SHA256 288f00a0efb7347634b4c66963a8b3c483cc7d1d526da9618e2a4ffded039923
MD5 0f9dfc20b8d6bb76ea64c8dcaca784c7
BLAKE2b-256 5d8bb89ad5a3d6b9ebd5411ca52f7bbd06ecfc3a3f1b3a745bac2e3cb02c59a0

See more details on using hashes here.

File details

Details for the file mirror_cli-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mirror_cli-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for mirror_cli-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4e8852711a6d30e8d3751827d2c41c8447cd047123a53611003975d208cbdee6
MD5 45074e6d040c6749effcf3ff74ec9bea
BLAKE2b-256 3dde406895081023bf7a5b644cec6a720e5230739500080c082fd9c53c1da398

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