Whenever the HTLC is consumed (by claiming the funds) how do we get the secret ? Is it included in the tx ?
The secret pre-image is in the argument given to the LogicSig.
You should be able to find it using Indexer v2.
Use for example https://developer.algorand.org/docs/reference/rest-apis/indexer/#get-v2transactions to get the transaction. Then, the hash should be transaction.signature.logicsig.args
: https://developer.algorand.org/docs/reference/rest-apis/indexer/#transactionsignaturelogicsig