Connecting to the Osmosis API with Python

Gary Sieling posted this on api

Ever wanted to connect to the Osmosis API using Python? Using core Python libraries, you can easily connect to our API and pull back results.

import urllib2
import simplejson
 
api_key = '--insert your API key here--'
url = 'https://www.getosmosis.com/api/Questionnaires/Draft?key=' + api_key
 
req = urllib2.Request(url, None, {'user-agent':'osmosis/api'})
opener = urllib2.build_opener()
f = opener.open(req)
print simplejson.load(f)
.

To get your API key, go to Osmosis Settings, and copy the key visible on the screen - make sure to keep this key safe, as it can be used to make modifications to your account.

14-day free trial. No credit card required. Sign Up for a Free Trial!