REDCap API Library for .NET The library provides the ability to interact with REDCap via API calls, e.g Import Records, Export Records etc. This library supports all supported API methods in REDCap. https://www.nuget.org/packages/RedcapAPI
Find a file
2024-11-07 18:17:31 -05:00
.github/workflows Merge branch 'master' into add_background_import_process 2024-07-10 11:38:44 -04:00
.vscode update assembly to match version 2020-08-25 12:28:33 -04:00
RedcapApi update package 2024-11-07 18:14:15 -05:00
RedcapApi.Tests update package 2024-11-07 18:14:15 -05:00
RedcapApiDemo update package 2024-11-07 18:14:15 -05:00
.gitattributes Add .gitignore and .gitattributes. 2017-07-28 14:17:14 -04:00
.gitignore Update .gitignore 2023-03-31 16:35:20 -04:00
.travis.yml update travis build configuration 2021-02-05 12:19:25 -05:00
azure-pipelines.yml Update azure-pipelines.yml for Azure Pipelines 2023-01-07 11:59:29 -05:00
LICENSE.md Rename license.md to LICENSE.md 2018-07-02 23:24:49 -04:00
README.md Update README.md 2024-11-07 18:09:46 -05:00
RedcapApi.sln Update RedcapApi.sln 2024-04-02 01:52:25 -04:00
vcu.png ShouldExportRecordAsync => FAIL 2021-02-03 21:02:57 -05:00

Build Status

NuGet license

REDCap API Library for .NET

The REDCap Api Library provides the ability to interact with REDCap programmatically using various .NET languages(C#,F#,VB.NET);

Prerequisites

  1. Local redcap instance installed (visit https://project-redcap.org) if you need to download files(assuming you have access)
  2. Create a new project with "Demographics" for the template; this gives you a basic project to work with.
  3. Create an api token for yourself, replace that with the tokens you see on the "RedcapApiTests.cs" files, and others
  4. You'll may need to add a field type of "file_upload" so that you can test the file upload interface of the API
  5. Build the solution, then run the demo project to see the results.

API METHODS SUPPORTED (Not all listed)

  • ExportLoggingAsync
  • ExportDagsAsync
  • ImportDagsAsync
  • DeleteDagsAsync
  • ExportArmsAsync
  • ImportArmsAsync
  • DeleteArmsAsync
  • ExportEventAsync
  • ImportEventAsync
  • ExportFileAsync
  • ImportFileAsync
  • DeleteFileAsync
  • ExportMetaDataAsync
  • ExportRecordsAsync
  • ImportRecordsAsync
  • ExportRedcapVersionAsync
  • ExportUsersAsync

Usage:

  1. dotnet restore
  2. Add reference to the library in your project, or download from nuget into project
  3. Add "using Redcap" namespace
  4. Add "using Redcap.Models" for convenience
  5. Replace the demo api token with your test project or you can import the data dictionary in \Docs thats provided for convenience.
  6. Feel free to contribute

Sample / Example


using Newtonsoft.Json;
using Redcap;

namespace RedcapApiDemo
{
    internal class Program
    {
        static async Task<int> Main(string[] args)
        {
            var apiToken = "3D57A7FA57C8A43F6C8803A84BB3957B";
            var redcap_api = new RedcapApi("http://localhost/redcap/api/");
            var result = await redcap_api.ExportRecordsAsync(apiToken);
            var records = JsonConvert.DeserializeObject(result);
            Console.WriteLine(records);
            Console.ReadLine();
            return 0;
        }
    }
}


Install directly in Package Manager Console or Command Line Interface

Package Manager

Install-Package RedcapAPI -Version 1.3.7

.NET CLI

dotnet add package RedcapAPI --version 1.3.7

Paket CLI

paket add RedcapAPI --version 1.3.7

Example Project

A console project has been included with the source code to get started. Some examples of method usage. You can use this to get started potentially.

Test Project

A project with associated test cases is included. Make sure to change the api token