Almost all block explorer APIs have this functionality among their transaction API calls. You should check out their API documentation for more details and see which one is easier for you to use.
Here is an example from blockcypher API using the first non-coinbase transaction of one of the latest blocks:
https://api.blockcypher.com/v1/btc/main/txs/ca1662e85e137fae3ec13dace7f4bf64801a1ebdc8433150566b2ae838498a8a
Response:
{
...
"confirmations": 2,
...
}
If the transaction is still in the mempool (unconfirmed) the value above shows as 0
.
Note that if the purpose is unimportant things such as showing donations using a block explorer is fine, otherwise if the purpose is receiving payments (eg. for a sale) it is a much better idea to use a different method such as running your own full or SPV node.