API to Query Historical Zcash Network Difficulty

I'm looking for an API that offers historical network difficulty by date range or period. Anybody know where I would find this?

I did find a site that graphed the difficulty and looking at the jQuery I was able to find the API call to retrieve the data - but unfortunately I cannot remember what the site was. Had a quick look and can't find it again.

But if you do come across an API for this, I'd be interested too..

Thanks. I think you may be referring to Coinwarz. Earlier today I ended up doing what you suggested. Some hacky python below, should anybody be interested:

https://zcha.in has a public API with TLS support, may be worth to consider.
Moar hacky snaeks:

#!/usr/bin/python2.7
#
# -*- unicode: utf-8 -*-
#
import urllib, json, decimal

u, U = urllib.URLopener(), 'https://api.zcha.in/v2/mainnet/network'
u.addheaders = [('User-Agent','Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Firefox/45.0'),('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')]
r = u.open_https(U[6:])

try:
        print 'ZEC current diff: %s' % format(decimal.Decimal(json.loads(r.read())['difficulty']), '.2f')
except:
        print 'Error: Got status code %i' % r.code()
1 Like

Thanks. I wasn't able to find an endpoint on zcha.in that provided historical difficulty.

The /blocks endpoint is the closest you'll get to viewing historical diff from their API as of current.

1 Like