elow you will find links to libraries and also examples of code in various programming languages for connecting to the REDCap API. Each section below represents a different programming language.
Please also take a look at the list of know REDCap API packages in various languages.
A simple Python library called PyCap (Python and REDCap) has been created for communicating with REDCap projects from Python applications. It mimics the REDCap API as much as possible and is designed to be very easy to use.http://sburns.github.com/PyCap/
The following code requires a reference to the Microsoft XML object library - v3.0 (msxml3.dll).
The function is tolerant of form changes in that it is designed to import only those columns whose names match between the REDCap form and the MSAccess table. It accomplishes this by checking the column name of each datum against a string of valid names, so it is not particularly efficient. If you know that every column name in the REDCap form also exists in the MSAccess table, and if the import is hideously time-consuming, you should remove that bit of code.
Developer: (Pete Charpentier peter.charpentier@yale.edu)
The strategy here is to use Stata's shell command to call out to curl to exchange data with REDCap.
Requirement: curl Software. See Section "Command Line Interface" on how to get curl
Download records: Issue the command, all on one line
whereAPITokenis your REDCap API token This will create the CSVfile filewith field names as the first row.
Then import the data into Stata using the command
Upload records: Export the data into a CSV file namedcsvfile with REDCap field name as the first line
Then uploadcsvfileto REDCap using
whereAPITokenis your REDCap API Token andcsvfileis the CSV file.
Upload and Download file from REDCap: To upload the file myfile as displayname to the File Upload Field file_field for the record record_id and event event_name
This command (all on one line) will reverse the process and download file from REDCap to the your computer as file downloadfile.
You can replace --output downloadfile with -O (capital 'O') to download myfile as file displayname in your current directory.
For more Stata examples go to https://github.com/lsgs/REDCap-API-and-Stata
There are two actively-developed R packages for REDCap (as of Oct 2014), redcapAPI and REDCapR. Entire operations typically require a line of two of R code. To see additional documentation or ask the developers questions, please see their development sites (redcapAPI and REDCapR). Thepackagesincludeextraerrorchecking, and facilitate many types of REDCap operations. Here is an example of each package exporting records from the server.
To call the API without redcapAPI or REDCapR, it's still advisable to use the RCurl or httr packages to facilitate the communication. Here is an example using RCurl.
Examples are in the attachment api_matlab.zip
Useurlreadto read/write record and download file.
For file upload, use redcapreadpostwhichisattachedasapi_matlab.zip. redcapreadpostisamodificationofurlreadpostwhichisavailableinsidethesamezipattachmentorfromMATLAB Central athttp://www.mathworks.com/matlabcentral/fileexchange/27189-urlreadpost-url-post-method-with-binary-file-uploading
urlreadpostcanuploadfiles. Itwillhoweverinsistonusingdummyasthe file name displayed on REDCap.redcapreadpostremove that restriction by allowing you to specify the display file name.
See also urlread2 at Matlab File Exchange. (On Oct 4th2012, the link is http://www.mathworks.com/matlabcentral/fileexchange/35693-urlread2 with a blog post on http://undocumentedmatlab.com/blog/expanding-urlreads-capabilities/ describing its function). Ithasthepotentialtoreplaceredcapredpost,urlreadpostandurlrread. However, I (Cinly Ooi) had never tested its claims.
Notes from 2017-05 by @andy.martin, we had luck using webread which allows some more flexibility in the headers (although we aren't using it) - but this worked:
Uses curl. On Unix and Linux, it is probably already installed as REDCap list the PHPversionofitasaoptionalmodule. If not, use your package manager to download and install curl. Windows user should follow the procedure below
ode below uses httpcore.jar and httpclient.jar from Apache HttpComponents