QuackUIInstall

Script an export

Download a report from a script, with fresh data or from a run.

Create a token with the scopes reports:read and data:read. Add runs:write for the second half.

export QUACKUI=https://bi.example.com
export QUACKUI_TOKEN=quackui_pat_...
auth="Authorization: Bearer $QUACKUI_TOKEN"

Find the report

curl -s -H "$auth" $QUACKUI/api/reports | jq -r '.reports[] | "\(.id)  \(.name)"'

Download it

curl -s -f -H "$auth" -H 'Content-Type: application/json' \
  -d '{"format":"xlsx"}' -o sales.xlsx \
  $QUACKUI/api/reports/$REPORT/export

format is xlsx, pdf or csv. CSV needs a blockId and PDF doesn’t take one. Without answers, prompts use their defaults.

If something was left out of the file, the response has an X-QuackUI-Export-Notices header holding URL-encoded JSON.

When the server has too many exports, it answers 503 with Retry-After.

Run it, then download the run

A run keeps a snapshot you can go back to.

run=$(curl -s -H "$auth" -H 'Content-Type: application/json' -d '{}' \
  $QUACKUI/api/reports/$REPORT/runs | jq -r .run.id)

while true; do
  status=$(curl -s -H "$auth" $QUACKUI/api/runs/$run | jq -r .run.status)
  case $status in queued|running) sleep 2 ;; *) break ;; esac
done
echo "$status"

curl -s -f -H "$auth" -H 'Content-Type: application/json' \
  -d '{"format":"pdf"}' -o sales.pdf $QUACKUI/api/runs/$run/export

Treat partial as a warning: some blocks failed, and the file says which.

Before you script it

If a schedule and a delivery would do, use those. They retry, keep history and need no token.