user46240: I would also like the the result to be precise to hour (or minute).
It is for a java program.
I have looked around, but the service I have found could not satisfy my need:
http://www.coindesk.com/api/: only precise to date
https://api.coinbase.com/v1/prices/historical?page=1 (from https://community.coinbase.com/t/past-bitcoin-exchange-rates/1725): need to adjust page number to find the desired time (at which one wants the value of exchange rate)
http://api.bitcoincharts.com/v1/csv/: I am not exactly sure what it does, but it seems that one needs to download different files from this site containing "USD" in the file names, check in all the files before finding the desired time  

user-1: The CoinGecko API is what you are looking for. Here an example request:
https://api.coingecko.com/api/v3/coins/bitcoin/history?date=28-06-2021

You can pipe it through jq:
curl https://api.coingecko.com/api/v3/coins/bitcoin/history?date=28-06-2021 | jq .market_data.current_price.usd

Which gives you 39076.59377063225. The exchange rate of bitcoin at the 28th of June 2021 in USD. It is not possible to get values for minutes/hours, just for days, as far as I am aware).

46240: <p>I would also like the the result to be precise to hour (or minute).</p>

<p>It is for a java program.</p>

<p>I have looked around, but the service I have found could not satisfy my need:
<a href="http://www.coindesk.com/api/" rel="nofollow noreferrer">http://www.coindesk.com/api/</a>: only precise to date</p>

<p><a href="https://api.coinbase.com/v1/prices/historical?page=1" rel="nofollow noreferrer">https://api.coinbase.com/v1/prices/historical?page=1</a> (from <a href="https://community.coinbase.com/t/past-bitcoin-exchange-rates/1725" rel="nofollow noreferrer">https://community.coinbase.com/t/past-bitcoin-exchange-rates/1725</a>): need to adjust page number to find the desired time (at which one wants the value of exchange rate)</p>

<p><a href="http://api.bitcoincharts.com/v1/csv/" rel="nofollow noreferrer">http://api.bitcoincharts.com/v1/csv/</a>: I am not exactly sure what it does, but it seems that one needs to download different files from this site containing "USD" in the file names, check in all the files before finding the desired time  </p>
 -1: <p>The <a href="https://www.coingecko.com/en/api#explore-api" rel="nofollow noreferrer">CoinGecko API</a> is what you are looking for. Here an example request:</p>
<pre><code>https://api.coingecko.com/api/v3/coins/bitcoin/history?date=28-06-2021
</code></pre>
<p>You can pipe it through <code>jq</code>:</p>
<pre><code>curl https://api.coingecko.com/api/v3/coins/bitcoin/history?date=28-06-2021 | jq .market_data.current_price.usd
</code></pre>
<p>Which gives you <code>39076.59377063225</code>. The exchange rate of bitcoin at the 28th of June 2021 in USD. It is not possible to get values for minutes/hours, just for days, as far as I am aware).</p>
