library("rds.r")
library("knitr")

Connecting to the RDS Server

Setting up the connection to the RDS server is the starting point to interacting with the RDS API through R. It provides an entry point to the API and will facilitate the handling of API calls for catalogs and data products.

# set up the base URL
url = "https://public.richdataservices.com/rds"

# connect to the server
rds <- get.rds(url)

The server will come with some basic information about it.

properties <- c("Name", "Version", "Base URL", "Disclaimer")
df <-
  data.frame(rds@name, rds@version, rds@baseUrl, rds@disclaimer)
names(df) <- properties
kable(df)

Retrieving the Catalogs

The server provides an entry point for users to view the catalog. We can get all the catalogs at once or a specific catalog by passing in the catalog id.

Get all Catalogs

catalogs <- rds.r::getCatalogs(rds)
catalogDf <- data.frame()
for (catalog in catalogs) {
  df <-
    data.frame(
      catalog@id,
      catalog@name,
      catalog@label,
      catalog@description,
      catalog@dataProductCount
    )
  catalogDf <- rbind(catalogDf, df)
}
names(catalogDf) <-
  c("ID", "Name", "Label", "Description", "# Data Products")

kable(catalogDf)

Get Specific Catalog

catalog <- rds.r::getCatalog(rds, "covid19")
df <-
  data.frame(
    catalog@id,
    catalog@name,
    catalog@label,
    catalog@description,
    catalog@dataProductCount
  )
names(df) <-
  c("ID", "Name", "Label", "Description", "# Data Products")
kable(df)


mtna/rds-r documentation built on July 30, 2023, 3:25 a.m.