@@ -0,0 +1,1845 @@
+#!/usr/bin/env python%0A%0Aimport sys%0Aimport urllib%0Aimport httplib%0Aimport argparse%0A%0A# example usage: ./export_records.py token=%3Ctoken%3E content=record format=xml%0A# ./export_records.py token=727D123244B55048136834EEB796D86E content=record format=csv%0A%0A# export records%0A# export_records.py token=727D123244B55048136834EEB796D86E content=record format=csv type=flat forms=demographics%0A# export_records.py token=727D123244B55048136834EEB796D86E content=record format=csv type=eav forms=cbc%0A%0A# Set the url and path to the API%0Ahost = '127.0.0.1:8998'%0Apath = '/redcap/api/'%0A%0Adef main():%0A%0A   parser = argparse.ArgumentParser(description='Read some data from a REDCap Project')%0A   parser.add_argument('--token', dest='token', default='727D123244B55048136834EEB796D86E',%0A                      help='Specify the authentication/authorization token that will provide access to the REDCap project')%0A   parser.add_argument('--content', dest='content', default='record',%0A                      help='Specify the kind of data to return')%0A   parser.add_argument('--format', dest='format', default='csv',%0A                      help='Specify the format for the returned data: csv, json, xml')%0A   parser.add_argument('--type', dest='type', default='eav',%0A                      help='Specify the type for the returned data: eav, flat')%0A   parser.add_argument('--forms', dest='forms',%0A                      help='Specify the forms whose values should be to returned')%0A   parser.add_argument('--fields', dest='fields',%0A                      help='Specify the fields whose values should be to returned')%0A%0A   args = vars(parser.parse_args())%0A%0A   c = httplib.HTTPConnection(host)%0A   c.request('POST', path, urllib.urlencode(args), %7B'Content-Type': 'application/x-www-form-urlencoded'%7D)%0A   r = c.getresponse()%0A   print(r.read())%0A   c.close()%0A%0Aif __name__ == '__main__':%0A   main()%0A

Add export_from_redcap.py, a tool to read data from a REDCap project using the REDCap API