You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 2 Next »

Introduction

In this article, we want to introduce a few ways to make a connection to the CDISC Library via REST API. To help you familiarize with CDISC Library and the REST API technology, we will discuss several methods or tools to obtain a catalog of standards available in the metadata repository.

Basic Concept

To obtain a catalog of standards available, you will, using a client, issue an API query in the form of URL: https://library.cdisc.org/api/mdr/products. We can break this REST API query into these components (punctuation combined to related component for brevity):

operationschemehostbase pathendpointpath parameter
GEThttps://library.cdisc.org/api/mdr/products{product-family}

operation: Method to be performed. GET is used for retrieving information

scheme: The transfer protocol of the API. Note: https should be used, not http

host: The host (name or IP) serving the API

base path: The base path on which the API is served, which is relative to the host

base URL: The combination of scheme, host, and base path

endpoint: The available paths and operations for the API

path parameter: The variable parts of an API query, use for pointing to a specific resource

Method 1: cURL

cURL is a free and open-source command-line tool that performs file transfer with a URL syntax. It supports a myriad of protocols and platforms. To run the API query above, the minimum requirements are:

curl --header api-key:abcdef0123456789abcdef0123456789
     --header Accept:application/json \
     --request GET https://library.cdisc.org/api/mdr/products

Method 2: Windows PowerShell

Similarly, below is a script written for Windows PowerShell that accomplishes the same objective. Notice you must add the API key in the request header (line #2) before sending the API query or you will see a "Unauthorized" message:

$headers=@{}
$headers.Add('api-key','key:abcdef0123456789abcdef0123456789')
$headers.Add('Accept','application/json')
$url = "https://library.cdisc.org/api/mdr/products"

$result = Invoke-WebRequest -Uri $url -Headers $headers -Method GET

Write-Output $result

Method 3: API Development Tools

Open-source and free API development tools are plentiful in the marketplace. Some of them are:

Method 4: Programming

Refer to Getting Started: Programmatically connect to CDISC Library API

Further Reading

cURL. Tool documentations. Manual page. https://curl.haxx.se/docs/manpage.html

  • No labels