KeePassXC also has a cli interface suitably named keepassxc-cli, so for TOTP in the terminal its something like:
keepassxc-cli show -q "$KEEPASS_DB_FILE" "$ENTRY_NAME" --totp
<type password>
<prints totp>
edit: doubly so specifically regarding Authy since theyre discontinuing it on the desktop in a few months.