We will be adding code snippets in other languages.
2020-11-11: Updated to use API key authentication
2020-07-07: Added XQuery examples
2019: 10-07: Added an R example
2019-07-09: Added a Java example
2019-05-25: Added a SAS example
In this article, you will find several ways to connect to the CDISC Library programmatically using REST API.
Fictitious API keys are used in these example code snippets. Substitute them the keys assigned to you, which are accessible via the API Management Developer Portal at https://api.developer.library.cdisc.org. To request a CDISC Library account to access the API Management Developer Portal, visit https://www.cdisc.org/cdisc-library/api-account-request.
The objective is to obtain a list of CDISC Controlled Terminology that are loaded into the metadata repository. Two libraries you will need to make a REST API request and store the JSON output:A REST API GET operation is basically a URL with three parts: base URL, endpoint, path.You may also specify the output format (or, media type). For JSON, you will specify to accept application/json in the request header:XML is an alternate output format you may specify:Link to download the full script: https://bitbucket.cdisc.org/snippets/1cf26161a1b640daad885dd57295e4c2/download.
Below is a sample program to also obtain a list of CDISC Controlled Terminology. This program is compatible with v9.4 and SAS OnDemand for Academics. For further reading about PROC HTTP, visit on-line documentation at https://documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=n1tv5bhcqw9q4ln1btjqicqdqws3.htm&locale=en. Example 9 discusses how to specify HEADER statements for a GET operation. For creating access to SAS OnDemand for Academics, visit https://www.sas.com/en_us/software/on-demand-for-academics.htm.Link to download this code snippet: https://bitbucket.cdisc.org/snippets/39a1fc0bb4f14ad5969dbb7282bae5dc/download.
Below is a basic CDISC Library client in Java. This example client, by Jozef Aerts, demonstrates how to get started creating a CDISC Library REST client in Java.Link to download this code snippet: https://bitbucket.cdisc.org/snippets/a8f0ceec50f24777932da48d7631cc28/download.
Below is a basic CDISC Library client in R, tested using R Studio v1.2.5 with R v3.6. This example demonstrates how to obtain a product catalog using the /mdr/products endpoint.Link to download this code snippet: https://bitbucket.cdisc.org/snippets/f6589a6c6f7d41239ea6ef0e8be0ce1e/download.
Below demonstrates how to request a quarter of SEND CT from CDISC Library using XQuery. For technical overview about XQuery, visit https://www.w3.org/TR/xquery/all/.Link to download this code snippet: https://bitbucket.cdisc.org/snippets/9e2db509e6ab43f7a3ac82f06a7aae53.
Also available is a Java program that incorporates this XQuery method: https://bitbucket.cdisc.org/snippets/5b4e4100c52b4fb2ac633f83d04a4251.