Skip to content

itzptk/yazio-go-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

yazio-go-cli

A scriptable Go CLI for the unofficial YAZIO API

CI Release Go version License: MIT


Read, search, add, and remove YAZIO diary data from your terminal.
Authenticate with your YAZIO account, fetch daily summaries, search products, and automate food logging.



Warning

This project relies on YAZIO's unofficial/private API. Endpoints, payloads, or authentication flows may change without notice and break the CLI.

✨ Features

Feature Description
πŸ” Email/password login Exchange YAZIO credentials for an API token and save it locally
♻️ Token persistence Persist and refresh API tokens automatically after login
πŸ‘€ User profile Fetch the current YAZIO user profile
πŸ“Š Daily summary Read nutrition summary data for today or a specific date
🍽️ Diary entries List consumed diary items for a date
πŸ” Product search Search products in the YAZIO database
βž• Add diary items Add consumed products with meal, serving, amount, and date metadata
πŸ—‘οΈ Remove entries Remove consumed diary entries by entry ID
βš™οΈ Config bootstrap Generate a starter config with yazio config init
🧾 Scriptable output Use table output for humans or JSON output for automation
πŸ“€ Diary CSV export Export one day or an inclusive date range of diary entries to CSV

⌨️ Usage

Quick start

yazio config init
yazio auth login --email you@example.com --password 'your-password'
yazio auth status

Or provide credentials through environment variables:

export YAZIO_EMAIL=you@example.com
export YAZIO_PASSWORD='your-password'
yazio auth login

Common commands

Command Description
yazio user profile Fetch the current user profile
yazio summary Fetch today's daily summary
yazio summary 2026-06-02 Fetch the daily summary for a date
yazio consumed 2026-06-02 List consumed diary entries for a date
yazio export diary 2026-06-02 Export one diary day as CSV to stdout
yazio export diary --from 2026-06-01 --to 2026-06-07 --file diary.csv Export an inclusive diary date range to a CSV file
yazio search banana Search products in the YAZIO database
yazio --output json summary 2026-06-02 Emit JSON for scripting

CSV exports write this header:

date,category,meal,entry_id,type,product_id,name,producer,amount,serving,serving_quantity,raw_json

If you pass --file, the CLI writes the CSV file and prints the exported entry count. Without --file, CSV goes to stdout for piping into other tools. Product rows use typed columns directly; recipe portions and simple products also include raw_json so unsupported YAZIO diary fields are not silently dropped.

Write operations

yazio add \
  --product-id 11111111-1111-1111-1111-111111111111 \
  --meal breakfast \
  --amount 100 \
  --serving g \
  --serving-quantity 1 \
  --date 2026-06-02

yazio remove 22222222-2222-2222-2222-222222222222

πŸš€ Installation

With Go install

go install github.com/itzptk/yazio-go-cli/cmd/yazio@latest

Download

When releases are published, grab the latest platform archive and checksums.txt from the Releases page.

Or build from source

git clone https://github.com/itzptk/yazio-go-cli.git
cd yazio-go-cli
go build -o bin/yazio ./cmd/yazio

βš™οΈ Configuration

Default config path:

~/.config/yazio-go-cli/config.yaml

Generate a starter config:

yazio config init

To overwrite an existing config file:

yazio config init --force

You can also copy the checked-in example manually:

mkdir -p ~/.config/yazio-go-cli
cp config.example.yaml ~/.config/yazio-go-cli/config.yaml

Override the config path per command:

yazio --config /path/to/config.yaml ...
Key Description
base_url Override the unofficial YAZIO API base URL
output Default output format: table or json
token Populated automatically after yazio auth login

🧱 Stack

Layer Technology
Language Go 1.24
CLI Framework Cobra
Config Viper + YAML
API Client Go net/http client for the unofficial YAZIO API
Identifiers google/uuid
Testing go test ./...
CI/CD GitHub Actions β€” CI, build-only artifacts, beta/stable release flow

πŸ› οΈ Development

git clone https://github.com/itzptk/yazio-go-cli.git
cd yazio-go-cli
make test
make build

Available targets

Command Description
make fmt Format Go source with go fmt ./...
make test Run go test ./...
make build Build bin/yazio
make docker-test Run tests in a Go 1.24 container
make docker-build Build bin/yazio in a Go 1.24 container

If you prefer direct Go commands:

go fmt ./...
go test ./...
go build -o bin/yazio ./cmd/yazio

πŸ“¦ Release Workflow

The GitHub Actions release flow supports stable releases, beta releases, and build-only artifact checks.

Trigger Release Type
workflow_dispatch stable with explicit version Latest release vX.Y.Z
Schedule every 6h or workflow_dispatch beta Pre-release vX.Y.Z-beta.N when main changed since the last beta
workflow_dispatch build-only CI artifact build without creating a GitHub Release

Release artifacts are published as platform archives named yazio-go-cli_<version>_<os>_<arch> with a checksums.txt file.


🀝 Contributing

Issues and pull requests are welcome.

When contributing:

  • keep the command surface small and practical
  • prefer narrow, well-tested endpoint coverage over broad speculative coverage
  • document behavior changes in the README
  • verify changes with real command output where possible

For usage questions, bugs, or API breakage reports, open an issue at https://github.com/itzptk/yazio-go-cli/issues. Include the CLI command, expected behavior, actual behavior, and whether the response came from the unofficial API.


πŸ§ͺ API Notes

This project was informed by existing reverse-engineered/community work:

  • controlado/go-yazio β€” unofficial Go client with token/auth patterns
  • juriadams/yazio β€” TypeScript client with endpoint shapes for summary, search, and consumed items
  • saganos/yazio_public_api β€” older Swagger-style API description and OAuth token notes

Current limitations:

  • Email/password auth is the only supported login flow
  • Apple/Google web-session import is not implemented
  • Because the API is unofficial, long-term compatibility is not guaranteed

The goal here is a focused, scriptable CLI rather than exhaustive API coverage.


πŸ“„ License

MIT Β© itzptk

About

A scriptable Go CLI for the unofficial YAZIO API

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors