The data is also stored on the block chain. Query every 2016 blocks to see the difficulty at that time. Here are some samples, can see block 131040 was a re-target.
# bitcoin-cli getblockhash 4032 | xargs bitcoin-cli getblock
{
"hash" : "00000000ca4b69045a03d7b20624def97a5366418648d5005e82fd3b345d20d0",
"time" : 1294031411,
"difficulty" : 1.00000000,
}
# bitcoin-cli getblockhash 131039 | xargs bitcoin-cli getblock
{
"hash" : "0000000000000e6e98694ccb8247aad63aaa1e2bec5a7be14329407e4cea6223",
"time" : 1308145551,
"difficulty" : 567269.53016242,
}
# bitcoin-cli getblockhash 131040 | xargs bitcoin-cli getblock
{
"hash" : "000000000000097aa651b8e19c448924586a8010721c8e7ea282a0272d425987",
"time" : 1308145774,
"difficulty" : 876954.49351354,
}
After having a look at the data, there may be a mistake in the first few data points. As far as I know the difficulty can’t drop below one, so the values given with zero irritate me. I would assume that they were one as well. – Murch – 2016-01-07T11:13:10.323
Thank you! This is exactly what I was looking for. Also, I'll adjust the 0 values, as you describe, before using the data. – timeSmith – 2016-01-07T11:27:52.633
I don't see any negative data points, but I do see a few 0 points. Bitcoin's difficulty can't go below 1 by consensus rule, I believe, so blockchain.info has some bad data here. – morsecoder – 2016-01-07T21:30:30.600