Pipe and chain commands
Every getstream api response is JSON on stdout, and the CLI exits non-zero on failure with the error on stderr. That makes it safe to compose in shell pipelines and scripts, with one rule: extract values with --jq. Raw responses shorten long arrays whenever stdin is not a terminal (CI steps, agent calls, anything detached) or NONINTERACTIVE is set, with a Long arrays truncated notice on stderr; --jq results always print in full. The jq expressions reference collects the expressions that come up most.
Chain one call into the next
Extract values with --jq, then feed them into another call. String results print JSON-encoded, so strip the quotes before interpolating them:
getstream api QueryChannels --request '{"limit":30}' \
--jq '.channels[].channel.cid' | tr -d '"' \
| while IFS= read -r cid; do
getstream api QueryChannels --request "{\"filter_conditions\":{\"cid\":\"$cid\"},\"state\":true}"
doneBranch on exit codes
The CLI exits 0 on success and non-zero on failure, with the error written to stderr. Keep stdout clean for the JSON payload:
if getstream api QueryChannels --request '{"limit":5}' > channels.json 2> error.log; then
jq '.channels | length' channels.json
else
echo "query failed:" >&2
cat error.log >&2
exit 1
fiCapture raw JSON like this only for small results. In a detached run, arrays past 25 elements are shortened; select what you need with --jq instead.
Export rows as CSV
@csv builds a CSV row from an array, but --jq returns it JSON-encoded, so each line prints double-quoted with its inner quotes escaped. Pipe through jq -r . to unwrap it into clean CSV:
getstream api QueryChannels --request '{"limit":30}' \
--jq '.channels[].channel | [.cid, .member_count] | @csv' | jq -r ."messaging:general",218
"team:engineering",74Related
- jq expressions reference: the
--jqexpressions that come up most - Query data: building the queries that feed the pipe
getstream apireference: full flag list