A few months ago I took part in the NBN R hack-evenings at the University of Sheffield. Unlike everyone else in the room I was coding in python.
import pynbn c = pynbn.connect('lionfish_pynbn','password'); sp = c.get_tvk(query='Bombus terrestris') #get the tvk (the "taxon version key" for buff tails) keys =  for res in sp['results']: k = res['ptaxonVersionKey'] keys.append(str(k)) print "%d species match this query string" % len(keys) print keys tvk = keys print "We'll use the first key (%s)" % tvk #we usually take the first item from this list (advice from the NBN hackday) obs = c.get_observations(tvks=[tvk], start_year=1990, end_year=2010) #get observations print "There are %d records for B. terrestris between 1990 and 2010" % len(obs)
I’ll shortly be adding this to pip, so it can be installed with,
pip install pynbn