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.
There is no python wrapper for the API, so I created one. Feel free to clone and use (and pull requests happily accepted)! An example to illustrate how to use the API is here:
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[0] 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